Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site umcp-cs.UUCP Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!ll-xn!topaz!lll-crg!gymble!umcp-cs!chris From: chris@umcp-cs.UUCP (Chris Torek) Newsgroups: net.lang.c Subject: Re: structure references in header files Message-ID: <2528@umcp-cs.UUCP> Date: Wed, 11-Dec-85 19:05:06 EST Article-I.D.: umcp-cs.2528 Posted: Wed Dec 11 19:05:06 1985 Date-Received: Fri, 13-Dec-85 08:51:34 EST References: <547@brl-tgr.ARPA> Organization: U of Maryland, Computer Science Dept., College Park, MD Lines: 46 Ai! Doug, how could you? You posted an example that is not even syntactically correct! C compilers are obliged by K&R to accept declarations of pointers to structure types even if those structure types have not yet been declared. That is, the following is legal: /* * Doubly linked list of node headers */ struct nodehead { struct nodehead *nh_next; struct nodehead *nh_prev; struct node *nh_front; /* <1> */ }; /* * Singly linked nodes with backpointers to the node header */ struct node { struct node *n_next; struct nodehead *n_head; /* <2> */ . . . }; If you intend to use anonymous structures and typedefs, e.g., typedef struct { ... } NODEHEAD; you still need a name for at least one of the two structures, as C compilers are allowed to be `one pass' and cannot infer that a name is a typedef that has yet to be compiled. At least one of the two marked references (<1> and <2>) must be to a `struct foo *', since at least one will be a forward reference no matter how you organise the declarations. I would check my X3J11 draft to see what it says, but someone `cleaned up' my desk. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251) UUCP: seismo!umcp-cs!chris CSNet: chris@umcp-cs ARPA: chris@mimsy.umd.edu