Article View: comp.std.c
Article #886Why can't you define an external object twice and never use it?
From: Paul Eggert
Date: Fri, 10 Nov 1989 02:57
Date: Fri, 10 Nov 1989 02:57
18 lines
1256 bytes
1256 bytes
The program
int X = 0;
int X = 0;
main() { return 0; }
is ``obviously'' not ANSI C, but where does the proposed ANSI standard say so?
X has multiple external definitions with external linkage, but X is never used.
3.1.2.2 prohibits the same identifier from appearing with both internal and
external linkage. 3.5's constraints prohibit multiple declarations of
identifiers with no linkage, and also prohibit declarations in the same scope
that refer to the same object but specify incompatible types. 3.7's
constraints prohibit multiple external definitions with internal linkage.
3.7's semantics prohibit multiple external definitions of any identifier that
is declared with external linkage and used in an expression.
However, none of these prohibitions apply to the above program. What's wrong?
Technical Details
Message-ID:
<53@looney.twinsun.com>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!ucla-cs!twinsun!rise.twinsun.com!eggertShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!ucla-cs!twinsun!rise.twinsun.com!eggert From: eggert@rise.twinsun.com (Paul Eggert) Newsgroups: comp.std.c Subject: Why can't you define an external object twice and never use it? Message-ID: <53@looney.twinsun.com> Date: 10 Nov 89 02:57:10 GMT Sender: news@twinsun.com Reply-To: eggert@twinsun.com (Paul Eggert) Organization: Twin Sun, Inc Lines: 18