Posted By: OCMvL
[SOLVED] typedef struct in header file not working - 12/26/15 21:23
Hey all, I found some strange behaviour that I don't understand.
The following code works in the main.c file. However it crashes when placed in a header file at line: "} CPlayer;". Can someone explain why? Am I missing something?
I tried various combinations, but all crash with a compiler error.
Thanks
The following code works in the main.c file. However it crashes when placed in a header file at line: "} CPlayer;". Can someone explain why? Am I missing something?
Code:
typedef struct CPlayerStruct { char* someString; int someInt; void someFunction(struct CPlayerStruct* p); } CPlayer;
I tried various combinations, but all crash with a compiler error.
Code:
typedef struct CPlayer { char* someString; int someInt; void someFunction(struct CPlayer* p); // CRASH } CPlayer; struct CPlayerStruct { char* someString; int someInt; void someFunction(struct CPlayerStruct* p); } typedef struct CPlayerStruct CPlayer; // CRASH
Thanks