struct a <---> struct b
The Stinkpuff
angst%csilvax at hub.ucsb.edu
Sun Feb 7 11:40:41 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)
I'm not sure what you mean by a forward referencing error. Since all
pointers are the same size, the compiler shouldn't care if it doesn't
yet know the object that is being pointed to. The following program
compiles fine on my machine (a VAX running 4.3BSD) --
struct a {
struct b *bp; /* forward reference */
struct c *cp; /* ditto */
int other_stuff;
};
struct b {
struct a *ap;
struct c *cp; /* forward reference */
int other_stuff;
};
struct c {
struct a *ap;
struct b *bp;
int other_stuff;
};
main ( )
{
}
Dave Stein "Life's a clambake."
ARPA: angst%csilvax at hub.ucsb.edu Disclaimer: college students don't
UUCP: ...ucbvax!hub!csilvax!angst need no disclaimers!
More information about the Comp.lang.c
mailing list