Forward Referencing of Static Variables OK?

Mike Banahan mikeb at inset.UUCP
Tue Oct 8 20:14:43 AEST 1985

The orginal article asked what should happen in this sort of case:

extern int xxx;

	xxx = 1;

static int xxx;	/* `extra' information about xxx */

The ANSI committee had a lot of work to do on this one.
There is an even worse issue than that:

	extern int xxx;	/* OH BOY!!! - where am I visible? */
			/* Am I really extern? */

	/* can I use xxx in here ???? */

They had to come up with a lot of words to fix that stuff - basically, it
just wan't written down anywhere what was supposed to happen. Bill Plauger
described the whole mess as ``Driving a coach and horses through block
structure.'' The more I look at it, the more I agree.

X3J11 has come up with a set of answers on what should happen. Because
nobody really ``knew'' before, you just get what your compiler happens to
give you. Be warned - it is *highly* nonportable practice, because
different compilers currently do different things. This is one area
where the language was already broken. The standard has chosen one way
of patching it.
Mike Banahan, Technical Director, The Instruction Set Ltd.

More information about the Comp.lang.c mailing list