Path: utzoo!utgpu!water!watmath!clyde!rutgers!rochester!bbn!uwmcsd1!ig!agate!ucbvax!ucsd!hub!angst%csilvax@hub.ucsb.edu From: angst%csilvax@hub.ucsb.edu (The Stinkpuff) Newsgroups: comp.lang.c Subject: Forward reference for structure? (Was: struct a <---> struct b) Message-ID: <359@hub.ucsb.edu> Date: 13 Feb 88 01:17:04 GMT References: <173@heurikon.UUCP> <341@hub.ucsb.edu> Sender: news@hub.ucsb.edu Reply-To: angst%csilvax@hub.ucsb.edu Distribution: na Organization: ///Club Angst!\\\ Lines: 34 In article <173@heurikon.UUCP> lampman@heurikon.UUCP (Ray Lampman) writes: >What is the best way to declare three different structures, each containing a pointer >to the other two? I keep running into a forward referencing error. I'm looking >for a solution without typedef's, I'll add those later. aTdHvAaNnKcSe, Ray. > - Ray Lampman (lampman@heurikon.UUCP) Sorry for beating a dead horse, but I'm confused about this forward referencing bit. I posted a response to this which included what I thought was a solution (because my program compiles *without* doing anything special w/regard to forward referencing), but the solutions posted by other people all do something to avoid forward referencing. Here is my program, compressed to save space: struct a { struct b *bp; struct c *cp; int other_stuff; }; struct b { struct a *ap; struct c *cp; int other_stuff; }; struct c { struct a *ap; struct b *bp; int other_stuff; }; main ( ) { } [This program compiles and runs fine on a VAX running 4.3BSD.] Can someone please enlighten me as to why there seems to be such a problem with this? The solutions I have seen so far have included defining "struct b" and "struct c" as "dummy" structures, or defining them as externs, prior to the declaration of "struct a." Since I did not have to go this trouble, could someone please enlighten me as to what's going on? Chris? Someone? Anyone... (If anyone would like to respond, why don't you email to me, and I will post a summary of the responses I receive. AdvTHANKSance.) Dave Stein Running without aim through the razor weeds that angst%csilvax@hub.ucsb.edu only reach my knees. And when I'm lying in the ...ucbvax!hub!csilvax!angst grey sleep, I don't know how to walk the boards.