mutual reference in structures

Heather Burris heather at maui.cs.ucla.edu
Fri May 5 10:54:26 AEST 1989


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_;
>
>
>-- 
>Bill <bouma at cs.purdue.edu>  ||  ...!purdue!bouma 

You cannot do forward references on typedefs.  You can, however,
on structure tags.  Therefore you can say:

typedef union a{
	struct b *pb;
}a_;

typedef struct b{
	a_ va;
}b_;

Note that the order of the above declarations is important because
I have not removed the typedef reference to typedef a_.  Have fun,

Heather Burris, UCLA



More information about the Comp.lang.c mailing list