Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!tkou02.enet.dec.com!diamond From: diamond@tkou02.enet.dec.com (diamond@tkovoa) Newsgroups: comp.std.c Subject: Re: Storage class conflicts and external linkage. Message-ID: <1931@tkou02.enet.dec.com> Date: 21 Aug 90 05:54:58 GMT References: <697@garth.UUCP> <13628@smoke.BRL.MIL> Reply-To: diamond@tkou02.enet.dec.com (diamond@tkovoa) Organization: Digital Equipment Corporation Japan , Tokyo Lines: 26 In article <13628@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes: >In article <697@garth.UUCP> baxter@garth.UUCP (Bill Baxter) writes: >>foo ( ) { extern void foo1( void ); } >>static foo1( ) {} >The first declaration of "foo1" gives it external linkage, the second >gives it internal linakge, thus the behavior is explicitly undefined. The first "foo1" has external linkage and the second "foo1" has internal linkage, but they are separate identifiers. The first "foo1" goes out of scope at the closing } of foo's block. Section 3.1.2.1. The following source file has two separate identifiers "bar": foo() { extern int bar; } static foo1( ) { auto int bar; } So does: foo() { extern int bar; } static int bar; static foo1( ) {} >>However, the declaration only has block scope. >That's not relevant. Linkage does not track scope. Linkage tracks identifiers, section 3.1.2.2. Identifiers track scopes, section 3.1.2.1. (Incidentally, Mr. Baxter's guess that block scope applies to the first foo1 is correct. There is a footnote in section 3.3.2.2.) -- Norman Diamond, Nihon DEC diamond@tkou02.enet.dec.com Steering like a sports car: I use opinions; the company uses the rack.