structure references in header files

Thomas Luteran txlutera at crdc.arpa
Wed Dec 11 12:40:10 AEST 1985



I have a problem with a header file that contains typedefs similar
to those below in that both contain a reference to the other.  The
problem stems from the fact second structure will be undefined
(not properly defined) when the first typedef tries to reference it: 

typedef struct car {
    int   numdoors;
    char  color[8];
    char  owner[20];
     .
     .
     .
    struct garage *parked;      <- using LOT here for struct garage won't 
    struct car    *next;
    } AUTO;		           work!			

typedef struct garage {
    char  location[20];
     .
     .
     .
    struct car *customers;
    struct garage *next;
    } LOT;

Please  send any replies directly to me  - Thanks in advance!

					Tom



More information about the Comp.lang.c mailing list