typedef struct tagQuad {
D3DXVECTOR3 vCoords[4];
QUADNODE* qChildren[4];
} QUADNODE;
I get an error on QUADNODE*: missing storage-class bla bla...
Basically I want that the struct points to itself. This is for a quadtree.
How can I do it??
Thanks,
Ivan
Structure pointing to self??
I have the following structure:
I changed QUADNODE* to tagQuad* and it compiled without grumbling.
What''s the difference though??
What''s the difference though??
it only works like this:
typedef struct tagQuad { D3DXVECTOR3 vCoords[4];tagQuad* qChildren[4]; } QUADNODE;
try forward declaring it...
Edit: This won't work, but kept it to show a bad example! Whee!
[edited by - stonicus on October 7, 2003 10:55:21 AM]
struct QUADNODE;typedef struct tagQuad{ D3DXVECTOR3 vCoords[4]; QUADNODE* qChildren[4];} QUADNODE;
Edit: This won't work, but kept it to show a bad example! Whee!
[edited by - stonicus on October 7, 2003 10:55:21 AM]
standard way of doing this is:
this compiles on VS.NET 2003.
ld
typedef struct tagQuad QUADNODE, *PQUADNODE;struct tagQuad { D3DXVECTOR3 vCoords[4]; QUADNODE* qChildren[4];};
this compiles on VS.NET 2003.
ld
That''s standardish for plain C, in C++ you don''t need to do any of that silly typedef stuff.
Here are the ways of doing it
Here are the ways of doing it
//Old C methodtypedef struct tagQUADNODE { D3DXVECTOR3 vCoords[4]; tagQUADNODE* qChildren[4];} QUADNODE;//C++ methodstruct QUADNODE { D3DXVECTOR3 vCoords[4]; QUADNODE* qChildren[4];};
Hey AikonIV, I tried the c++ method and it does not compile. the c method works though. Strange.
quote:Original post by cryo75
Hey AikonIV, I tried the c++ method and it does not compile. the c method works though. Strange.
The first one works, because the struct doesn''t rely on the typedef statement during the structure. You can''t reference the name of the typedef until after the closing brace of the struct declaration, because it simply doesn''t exist at that point.
typedef struct tagQUADNODE { D3DXVECTOR3 vCoords[4]; tagQUADNODE* qChildren[4]; // QUADNODE doesn''t exist here.} QUADNODE; // It exists here, though.
It''s like trying to reference something that isn''t complete yet. The typedef needs all the information from the struct''s declaration, in order to create the typedef itself. That means, that until it''s processed the declaration, the typedef isn''t created.
-hellz
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement