Storage class conflicts and external linkage.

diamond@tkovoa diamond at tkou02.enet.dec.com
Tue Aug 21 15:54:58 AEST 1990


In article <13628 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>In article <697 at garth.UUCP> baxter at 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 at tkou02.enet.dec.com
Steering like a sports car:  I use opinions; the company uses the rack.



More information about the Comp.std.c mailing list