Gamestudio Links
Zorro Links
Newest Posts
FXCM => AVA Trade Plugin???
by Martin_HH. 11/17/26 17:02
contractUpdate() is filtering if >2 rows
by mistery. 11/09/26 12:06
New Zorro version 3.15
by jcl. 11/09/26 09:24
Removing outliers from files
by jcl. 11/04/26 10:30
[MED] Import from FBX (2010) missing!!!
by rayp. 11/03/26 14:33
What are you working on?
by rayp. 11/02/26 13:57
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
3 registered members (Martin_HH, Quad, 1 invisible), 26,128 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rht, MaliceTheMaker, Haitao_Ren, JimSimons, julienp
19249 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