Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (Quad, 1 invisible), 877 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[SOLVED] typedef struct in header file not working #457115
12/26/15 21:23
12/26/15 21:23
Joined: Nov 2010
Posts: 8
Berlin
OCMvL Offline OP
Newbie
OCMvL  Offline OP
Newbie

Joined: Nov 2010
Posts: 8
Berlin
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?

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

Last edited by OCMvL; 12/26/15 22:30. Reason: Problem solved
Re: typedef struct in header file not working [Re: OCMvL] #457116
12/26/15 22:01
12/26/15 22:01
Joined: May 2008
Posts: 2,113
NRW/Germany
alibaba Offline
Expert
alibaba  Offline
Expert

Joined: May 2008
Posts: 2,113
NRW/Germany
Is acknex.h included before?


Professional Edition
A8.47.1
--------------------
http://www.yueklet.de
Re: typedef struct in header file not working [Re: alibaba] #457117
12/26/15 22:30
12/26/15 22:30
Joined: Nov 2010
Posts: 8
Berlin
OCMvL Offline OP
Newbie
OCMvL  Offline OP
Newbie

Joined: Nov 2010
Posts: 8
Berlin
Yeah it was. Thanks for the answer!

Found the problem however, my stupidity wink
The include-guard defined CPLAYER, so that word was reserved already.


Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1