I get two compile errors for ALLEGRO_FONT *fonts[FONT_MAX]; in graphics.h :- syntax error: missing '{' before '*' - identifier "ALLEGRO_FONT" is undefined
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?Any help?
graphics.h
graphics.c
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*.
Including header file works, predeclare does not.Any idea why other types as ALLEGRO_BITMAP and ALLEGRO_DISPLAY work?
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.
With typedef i get: 'typedef ': ignored on left of 'ALLEGRO_FONT' when no variable is declared
These are only headers i include in main.cAre ALLEGRO_BITMAP and ALLEGRO_DISPLAY defined in allegro.h?
main.c headers
edit: I just peeked at allegro.h and it includes bitmap.h that defines ALLEGRO_BITMAP. This solves my confusion Thanks
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;
That works!