Forward Referencing of Static Variables OK?

Stanley Friesen friesen at psivax.UUCP
Sat Oct 5 02:23:21 AEST 1985


In article <365 at tekcbi.UUCP> jimpr at tekcbi.UUCP writes:
>A C compiler we are using was designed in such a way that the following
>code would not compile:
>
>	extern int thing;	/* don't know yet if thing is static or not */
		.
		.
		.
>	static int thing = 0;	/* now we know that it's static */
>
>Their contention that not allowing this type of forward referencing of
>static variables is consistent with "The C Programming Language", (K. & P.).
>
(Various other compilers are mentioned)
>They all make "thing" static (ie, local to the file "thing" is defined in).
>
>What say you all?  Is there any language in K & P which would dissuade them?
>Thanks!
>
	Well, I cannot find anything explicit in K&R, but the ANSI
Draft Standard fairly clearly indicates that this *is*(or will be)
legal. So any compiler which wants to conform th the std will have
to accept this construct.
-- 

				Sarima (Stanley Friesen)

UUCP: {ttidca|ihnp4|sdcrdcf|quad1|nrcvax|bellcore|logico}!psivax!friesen
ARPA: ttidca!psivax!friesen at rand-unix.arpa



More information about the Comp.lang.c mailing list