Gamestudio Links
Zorro Links
Newest Posts
Z9 getting Error 058
by k_ivan. 04/20/26 15:57
Stooq now requires an API key
by jcl. 04/13/26 09:42
Strange "Alien" Skull created with >Knubber<
by NeoDumont. 04/10/26 18:58
400 free seamless texture pack downl. here !
by NeoDumont. 04/08/26 19:55
ZorroGPT
by TipmyPip. 04/08/26 17:08
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (TipmyPip, Grant, AndrewAMD), 3,498 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
juergenwue, VladMak, Geir, ondrej, mredit
19208 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