mutual reference in structures

Barton E. Schaefer schaefer at ogccse.ogc.edu
Sat May 6 02:21:15 AEST 1989


In article <23608 at shemp.CS.UCLA.EDU> heather at cs.ucla.edu (Heather Burris) writes:
} In article <6712 at medusa.cs.purdue.edu> bouma at cs.purdue.EDU (William J. Bouma) writes:
} >Please tell me how to get C to accept the following or equivalent code:
} >
} >typedef union a {
} >    b_ *pb;
} >} a_;
} >
} >typedef struct b {
} >    a_ va;
} >} b_;
} 
} You cannot do forward references on typedefs.  You can, however,
} on structure tags.

Both DYNIX cc and gcc -ansi -pedantic accept the following without complaint:

/* --------------- */
typedef struct b b_;

typedef struct a {
	b_ *bp;
} a_;

struct b {
	a_ *ap;
};
/* --------------- */

Is there something I'm missing here?
-- 
Bart Schaefer       "And if you believe that, you'll believe anything."
							-- DangerMouse
CSNET / Internet                schaefer at cse.ogc.edu
UUCP                            ...{sun,tektronix,verdix}!ogccse!schaefer



More information about the Comp.lang.c mailing list