|
Problems with ALLEGRO_FONT |
Aleksa
Member #14,874
January 2013
|
I get two compile errors for ALLEGRO_FONT *fonts[FONT_MAX]; in graphics.h : Strange thing is that ALLEGRO_BITMAP and ALLEGRO_DISPLAY work ok. If I include allegro_fonts in main or that exact .h file it works but that's not what i should do? graphics.h 1#pragma once
2
3enum {
4 IMAGE_BACKGROUND,
5 IMAGE_MAX
6};
7
8enum {
9 FONT_PROGGYCLEANSZ_23,
10 FONT_MAX
11};
12
13ALLEGRO_BITMAP *images[IMAGE_MAX];
14ALLEGRO_FONT *fonts[FONT_MAX];
15ALLEGRO_DISPLAY *display;
graphics.c 2#include <allegro5\allegro.h>
3#include <allegro5\allegro_native_dialog.h>
4#include <allegro5\allegro_image.h>
5#include <allegro5\allegro_font.h>
6#include <allegro5\allegro_ttf.h>
7#include <allegro5\allegro_primitives.h>
8
9#include "graphics.h"
10
11
12//LOADING STUFF
|
Edgar Reynaldo
Major Reynaldo
May 2007
|
You have to either include the allegro headers in your header file, or predeclare the types that you are using : #include "allegro_font.h" ALLEGRO_FONT* font;
struct ALLEGRO_FONT; ALLEGRO_FONT* font;
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Aleksa
Member #14,874
January 2013
|
Including header file works, predeclare does not. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Try typedef struct ALLEGRO_FONT instead. The other types probably work because you've included other headers before including your graphics.h header. You have to include the headers at some point. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Aleksa
Member #14,874
January 2013
|
With typedef i get: 'typedef ': ignored on left of 'ALLEGRO_FONT' when no variable is declared These are only headers i include in main.c main.c headers 1#include <stdbool.h>
2#include <stdio.h>
3
4#include <allegro5\allegro.h>
5#include <allegro5\allegro_native_dialog.h>
6
7#include "keyboard.h"
8#include "graphics.h"
edit: I just peeked at allegro.h and it includes bitmap.h that defines ALLEGRO_BITMAP. This solves my confusion |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Since you're using C I think you need to include 'struct' anytime you declare a variable of that type, unless it is after it has been typedef'ed. struct ALLEGRO_FONT* font[3]; #include "allegro5/allegro_font.h" /** in allegro_font.h typedef struct ALLEGRO_FONT {...}; */ ALLEGRO_FONT* font;
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Aleksa
Member #14,874
January 2013
|
|
|