Possible Duplicate:
Circular definition in C
typedef struct{
node *next;
node *last;
} doubleLink;
typedef struct{
doubleLink doubleLink;
int data;
} node;
The above is a doomed attempt to define an object with a double link.
Placing either typedef before the other would draw a compilation error of “unknown type”
One obvious recourse is to change the pointer type specifier in doubleLink to void *
But I wonder whether there are more “harmless” solutions, say, maybe
I can declare the node struct without defining it?
I’m cognizant that this must be a frequently asked question, but I don’t know by what keyword can I possibly find it.
Add forward declacation of
node:As you use pointers, you don’t need to have this type completely defined before the definition of
doubleLink.