Article View: comp.std.c
Article #1616Re: typedef + extern
From: Henry Spencer
Date: Tue, 21 Aug 1990 18:07
Date: Tue, 21 Aug 1990 18:07
25 lines
1428 bytes
1428 bytes
In article <1990Aug21.083324.13542@santra.uucp> sja@sirius.hut.fi (Sakari Jalovaara) writes:
> typedef int x;
>
> void f () { extern int x; x = 5; }
>
>Is the second declaration of "x" legal?
Unfortunately, yes, although you cannot use `extern x;' as shorthand for
it -- that means something entirely different! As K&R1 said: "It is
agreed that the ice is thin here."
In my experimental C parser, the line that handles this is commented:
"The Syntax From The Black Lagoon". It is really painful to have to
feed scope information back to the scanner so it can decide whether a
given identifier is a type name or not. Bad enough that it has to
make the decision in the first place...
>If it is, what linkage does "x" have? 3.1.2.2 would suggest that the
>second declaration "has the same linkage as any visible declaration of
>the identifier with file scope" -- i.e. none?
Methinks this qualifies as a slight oversight in the wording. :-)
--
Committees do harm merely by existing. | Henry Spencer at U of Toronto Zoology
-Freeman Dyson | henry@zoo.toronto.edu utzoo!henry
Technical Details
Message-ID:
<1990Aug21.180702.25027@zoo.toronto.edu>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<1990Aug21.083324.13542@santra.uucp>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: typedef + extern Message-ID: <1990Aug21.180702.25027@zoo.toronto.edu> Organization: U of Toronto Zoology References: <1990Aug21.083324.13542@santra.uucp> Date: Tue, 21 Aug 90 18:07:02 GMT