I’m defining some structs which reference eachother, and typedef’ing the structs before using them, so each struct is ‘aware’ of the others (was getting compilation errors without this). Not sure if this is necessary, or correct.
Now when compiling with gcc, I’m getting “redefinition of typedef” warnings. What’s the correct way to go about this?
typedef struct a A;
typedef struct b B;
typedef struct c C;
struct a {
B* list;
A* parent;
};
struct b {
A* current;
B* next;
};
struct c {
A* current;
A* root;
};
UPDATE:
Dumb, bad copy-pasting resulted in this header being included twice in another file. I’m new to C and thought it must have something to do with having the structs in the file twice. Thanks @Kevin Ballard for the heads up.
This is a good example of why header/include guards are needed: