Forward Referencing of Static Variables OK?

Bill Crews bc at cyb-eng.UUCP
Sat Oct 5 14:26:59 AEST 1985


> extern int thing;
> ...
> static int thing = 0;
> 
> is perfectly legitimate according to X3J11.
> Why waste time trying to relate this to K&R (not K&P).
> Point out to your compiler supplier that they're
> going to have to fix this anyway.

I know you're always (usually?) right, Doug, but this seems to me to be
an ambiguity.  One might have the symbol 'thing' defined in another
module to be linked with this one, and a reference to 'thing' that appears
between the above 'extern' and 'static' might be thought to refer to the
external symbol, since the scope of a static is from the definition point
through the end of the block or source file, depending upon where it is
defined.  Not so?
-- 
  /  \    Bill Crews
 ( bc )   Cyb Systems, Inc
  \__/    Austin, Texas

[ gatech | ihnp4 | nbires | seismo | ucbvax ] ! ut-sally ! cyb-eng ! bc



More information about the Comp.lang.c mailing list