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
1 registered members (TipmyPip), 18,619 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
Struct prototype? #180140
01/27/08 14:59
01/27/08 14:59
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline OP
Member
Fenriswolf  Offline OP
Member
F

Joined: Jan 2007
Posts: 221
Hello,

is it somehow possible to have struct prototypes?

I would like to declare circular types.

However, the following code does not work:

Code:

struct PARENT; // this is intended to be a struct prototype

typedef struct CHILD {
PARENT* parent;
} CHILD;

typedef struct PARENT {
CHILD* child;
} PARENT;



I receive the following compiler error message:
Quote:

PARENT (struct) undeclared identifier
struct PARENT;




Thanks

Re: Struct prototype? [Re: Fenriswolf] #180141
01/27/08 15:26
01/27/08 15:26
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
Normally you would do this like so:

Code:

typedef struct PARENT PARENT;
typedef struct CHILD CHILD;

struct CHILD {
PARENT *parent;
};
struct PARENT {
CHILD *child;
};



But that doesn't work, so I think it's a bug.

Re: Struct prototype? [Re: Fenriswolf] #180142
01/27/08 17:05
01/27/08 17:05
Joined: Jul 2001
Posts: 6,904
H
HeelX Offline
Senior Expert
HeelX  Offline
Senior Expert
H

Joined: Jul 2001
Posts: 6,904
Use void*'s instead and do safe typecasting.

Re: Struct prototype? [Re: HeelX] #180143
01/27/08 18:26
01/27/08 18:26
Joined: Jan 2007
Posts: 221
F
Fenriswolf Offline OP
Member
Fenriswolf  Offline OP
Member
F

Joined: Jan 2007
Posts: 221
Thank you both very much for your help!

With void* and some typecasting it works fine now.


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