Forward reference for structure? (Was: struct a <---> struct b)
The Stinkpuff
angst%csilvax at hub.ucsb.edu
Sat Feb 13 11:17:04 AEST 1988
In article <173 at heurikon.UUCP> lampman at 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 at 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 at 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.
More information about the Comp.lang.c
mailing list