initializing static mutually referencing structures
Larry Jones
scjones at thor.UUCP
Fri Sep 21 23:16:09 AEST 1990
In article <1287 at granjon.UUCP>, jhpb at granjon.UUCP (Joseph H. Buehler) writes:
> I have some structures that refer to each other, that I want to be
> static. The compiler doesn't like the following because it doesn't know
> what y is when it's initializing x:
>
> static struct xtag x = {&y};
> static struct ytag y = {&x};
>
> Does ANSI C have any way to do this?
static struct ytag y; /* tentative definition */
static struct xtag x = {&y};
static struct ytag y = {&x}; /* actual definition */
> For now, I had to drop the static and put an extern at the top of the file
Which is what you'll have to do for most non-ANSI compilers.
----
Larry Jones UUCP: uunet!sdrc!thor!scjones
SDRC scjones at thor.UUCP
2000 Eastman Dr. BIX: ltl
Milford, OH 45150-2789 AT&T: (513) 576-2070
I'm not a vegetarian! I'm a dessertarian. -- Calvin
More information about the Comp.lang.c
mailing list