Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/20/24 01:28
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (7th_zorro), 793 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 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 | 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