In article <50**************************@posting.google.com >
Steve Kobes <st*********@hotmail.com> writes:
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.
I believe this is correct.
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).
I believe this footnote refers instead to code such as this:
static int x;
void f(void) {
auto int x; /* hides "static" one; "auto" keyword for ref below */
{
extern int x;
...
}
}
Here the block-scope "auto" x has made the file-scope "x", with its
static duration, invisible. The "extern" line can no longer see it.
Note, however, that comp.lang.c is not the best group for questions
of the form: "what do these particular words in this particular
paragraph on this particular page of the C standard mean?" Along
with proposals for future standards, questions about interpretation
of current (and even past) standards is the domain of comp.std.c.
--
In-Real-Life: Chris Torek, Wind River Systems
Salt Lake City, UT, USA (40°39.22'N, 111°50.29'W) +1 801 277 2603
email: forget about it
http://web.torek.net/torek/index.html
Reading email is like searching for food in the garbage, thanks to spammers.