typedefs that need each other

Kaleb Keithley kaleb at thyme.jpl.nasa.gov
Wed Jan 16 06:04:45 AEST 1991


In article burley at geech.ai.mit.edu (Craig Burley) and by inference
jdb at reef.cis.ufl.edu (Brian K. W. Hook) wrote:
>   Scenario:
>
>   typedef struct _struct1 {
>	   .....
>	   STRUCT2 *structure;
>	   .....
>   } STRUCT1;
>
>   typedef struct _struct2 {
>	   .....
>	   STRUCT1 *structure;
>	   .....
>   } STRUCT2;
>

K&R2 in section 6.7 Typedef (on page 146) shows exactly how to do this 
with typedefs, and the above example would be:

    typedef struct _struct2 *STRUCT2ptr

    typedef struct _struct1 {
        .....
        STRUCT2ptr structure;
        .....
    } STRUCT1;

    typedef struct _struct2 {
 	   .....
 	   STRUCT1 *structure;
 	   .....
    } STRUCT2;


-- 
Kaleb Keithley                      Jet Propulsion Labs
kaleb at thyme.jpl.nasa.gov

Offensive quote coming soon to a .signature file near you.



More information about the Comp.lang.c mailing list