Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
2 registered members (OptimusPrime, AndrewAMD), 14,580 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 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 | 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