typedefs that need each other

Doug Gwyn gwyn at smoke.brl.mil
Sat Jan 12 10:11:22 AEST 1991


In article <26261 at uflorida.cis.ufl.EDU> jdb at reef.cis.ufl.edu (Brian K. W. Hook) writes:
>typedef struct _struct1 {
>	STRUCT2 *structure;
>} STRUCT1;
>typedef struct _struct2 {
>	STRUCT1 *structure;
>} STRUCT2;

You cannot use an identifier as a typedef before the identifer IS a typedef!
However, you can use incomplete types in contexts such as this.  For instance:

struct _struct2;	/* optional in most cases, but recommended */
struct _struct1 {
	struct _struct2 *structure;
};
struct _struct2 {
	struct _struct1 *structure;
};
typedef struct _struct1 STRUCT1;
typedef struct _struct2 STRUCT2;



More information about the Comp.lang.c mailing list