Path: utzoo!utgpu!attcan!uunet!virtech!cpcahil From: cpcahil@virtech.UUCP (Conor P. Cahill) Newsgroups: comp.lang.c Subject: Re: question about scope & linkage Keywords: scope, linkage Message-ID: <1002@virtech.UUCP> Date: 12 Aug 89 01:13:43 GMT References: <57257@tut.cis.ohio-state.edu> <1001@virtech.UUCP> <14270@haddock.ima.isc.com> Distribution: na Organization: Virtual Technologies Inc Lines: 38 In article <14270@haddock.ima.isc.com>, karl@haddock.ima.isc.com (Karl Heuer) writes: > In article <1001@virtech.UUCP> cpcahil@virtech.UUCP (Conor P. Cahill) writes: > >[Stuff about real vs. tentative definitions] A global symbol may have > >unlimited tentative definitions, but only 1 real definition. > > I think you're confusing tentative definitions with non-defining declarations. I am not. > > >In other words, you can have "int i;" in every .c and they will all refer to > >the same data space. > > This is not correct. A tentative definition retroactively becomes a real > definition if the end of the source file is reached without seeing a real > definition. The purpose of the tentative-definition nonsense is not to force > the Common-block storage model to work; it's to allow forward reference to > non-global identifiers. > 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, ...In the alternate formulation, which is usual in UNIX systems and recognized as a common extension by the Standard, all tentative definitions for an externally linked object, throughout ALL the translation units of a program are cosidered together instead of in each translation unit separately. If a definition occurs somewhere in the program, then the tentative definitions become merely declarations, but if no definition appears, then all its tentative definitions become a definition with initializer 0. "tentative definition" is defined as "an external object declaration that does not have an initializer, and does not contain the extern specifier" Therefore what I said is absolutely correct. BTW, I don't see how any of this applies to a "forward reference to non-global identifiers".