Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!mcnc!decvax!ima!haddock!karl
From: karl@haddock.ima.isc.com (Karl Heuer)
Newsgroups: comp.lang.c
Subject: Re: question about scope & linkage
Keywords: scope, linkage
Message-ID: <14279@haddock.ima.isc.com>
Date: 13 Aug 89 18:47:35 GMT
References: <57257@tut.cis.ohio-state.edu> <1001@virtech.UUCP> <14270@haddock.ima.isc.com> <1002@virtech.UUCP>
Reply-To: karl@haddock.ima.isc.com (Karl Heuer)
Distribution: na
Organization: Interactive Systems, Boston
Lines: 20

In article <1002@virtech.UUCP> cpcahil@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@haddock.isc.com), The Walking Lint