Re: loop in strucures definition



riccardo <riccardo@xxxxxxxxx> wrote:

typedef struct {
foo2 a;
} foo1;

typedef struct {
foo1 b;
} foo2;

foo2 is not defined yet when used to define foo1.
Placing the foo2 definition before foo1 doesn't help of course.
How can I solve this in a clean way?

Method 1:

typedef struct foo1 {
struct foo2 a;
} foo1;

typedef struct foo2 {
struct foo1 b;
} foo2;

Method 2:

typedef struct foo1 foo1;
typedef struct foo2 foo2;
struct foo1 {
foo2 a;
};

struct foo2 {
foo1 b;
};
--
Larry Jones

Hmph. -- Calvin
.