Hi
I'm having problems getting my structs to compile. I tried to find a solution from my K&R C book and the web, but couldn't. It's really annoying, because it's probably just some syntax problem, but I just can't figure it out.
Basically I'm trying to have two structs that both contain member whose type is the other struct.
Here's the problem ( simplified from my code ):
a.h:
Code:
#ifndef _A_H_
#define _A_H_
#include"b.h"
typedef struct{
b_struct bs;
} a_struct;
#endif
b.h:
Code:
#ifndef _B_H_
#define _B_H_
#include"a.h"
typedef struct{
a_struct as;
} b_struct;
#endif
c.c:
When I try to compile, I get:
C:\Program Files\eclipse\workspace\testi>gcc c.c
In file included from a.h:4,
from c.c:1:
b.h:7: error: parse error before "a_struct"
b.h:7: warning: no semicolon at end of struct or union
b.h:8: warning: data definition has no type or storage class
In file included from c.c:1:
a.h:7: error: parse error before "b_struct"
a.h:7: warning: no semicolon at end of struct or union
a.h:8: warning: data definition has no type or storage class
What's wrong and how to fix it?
Thanks for reading and for any advice/pointers in advance.