S
Steve Kobes
Consider
static int x;
void f()
{
extern int x; /* internal or external linkage? */
}
C99 6.2.2.4 says that "extern" causes an identifier's declaration to
inherit a previously specified linkage when it occurs "in a scope in
which a prior declaration of that identifier is visible". One might
think this means the inner x has internal linkage. Visual C++ 6 seems
to think so too.
But the footnote immediately afterward says, "As specified in 6.2.1
[scopes], the later declaration might hide the prior declaration." If
this footnote is to make sense, the inner x would have external
linkage, because its declaration hides that of the outer x. If so, it
is a bug in VC++ (which of course would not be all that surprising).
Which interpretation is correct?
static int x;
void f()
{
extern int x; /* internal or external linkage? */
}
C99 6.2.2.4 says that "extern" causes an identifier's declaration to
inherit a previously specified linkage when it occurs "in a scope in
which a prior declaration of that identifier is visible". One might
think this means the inner x has internal linkage. Visual C++ 6 seems
to think so too.
But the footnote immediately afterward says, "As specified in 6.2.1
[scopes], the later declaration might hide the prior declaration." If
this footnote is to make sense, the inner x would have external
linkage, because its declaration hides that of the outer x. If so, it
is a bug in VC++ (which of course would not be all that surprising).
Which interpretation is correct?