initializing static mutually referencing structures

Joseph H. Buehler jhpb at granjon.UUCP
Tue Sep 18 02:32:47 AEST 1990


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?  For now, I had to drop the static
and put an extern at the top of the file:

	extern struct ytag y;

	struct xtag x = {
		&y;
	};

	struct ytag y = {
		&x;
	};

Which is OK, I guess, but the structures really don't need global
accessibility.
--
Joe Buehler



More information about the Comp.lang.c mailing list