question about scope & linkage

Karl Heuer karl at haddock.ima.isc.com
Mon Aug 14 04:47:35 AEST 1989


In article <1002 at virtech.UUCP> cpcahil at virtech.UUCP (Conor P. Cahill) writes:
>A tentative definition of a data object is not resolved at the end of source
>module,  but at link time.  I quote from K&R2 pg 227 ...

As Doug mentioned, this is a Common Extension, not guaranteed to work on all
conforming implementations.

>BTW, I don't see how any of this applies to a "forward reference to
>non-global identifiers".

Consider a source file that contains
	static int x;
	int f() { return x; }
	static int x = 3;
The third line is the real definition of x; the second line contains a forward
reference to it, which is enabled by the tentative definition on the first
line.  In pre-ANSI C, this was not legal because "static int x;" was a real
definition with implied initializer zero (at least in some linkage models).

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.lang.c mailing list