Article View: comp.std.c
Article #2522Re: A question about tentative definitions
From: Paul Eggert
Date: Tue, 05 Mar 1991 20:01
Date: Tue, 05 Mar 1991 20:01
40 lines
1679 bytes
1679 bytes
rfg@lupine.ncd.com (Ron Guilmette) asks whether an implementation
should report an error given the two files
a.c:
int w;
b.c:
int w;
It's implementation-dependent. This is covered at length in the
Rationale's 3.1.2.2. Even though this usage is not strictly
conforming, a conforming implementation need not report this usage as
an error, because the relevant rules in 3.7 are listed under
``Semantics'', not under ``Constraints''. The traditional Unix
interpretation is a common extension. Other extensions are possible.
For example, a conforming implementation can also accept the following
extension:
d.c:
int x = 0;
e.c:
int x = 0;
Indeed, a conforming implementation resolve disputes among external
definitions in separate translation units using any method it likes.
For example, it can discard zero initializers in such situations, which
would allow the following:
f.c:
int y = 0;
g.c:
int y = 5;
and would initialize y to 5. Although I don't recommend this last
extension, it is a tempting one with the traditional Unix linker,
because it generates smaller executables in the more common case of
h.c:
int z[1000] = {0};
i.c:
int z[1000];
Technical Details
Message-ID:
<1991Mar5.200127.13306@twinsun.com>Path:
arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!orion.oac.uci.edu!ucivax!ucla-cs!twinsun!eggertReferences:
<4218@lupine.NCD.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!usc!orion.oac.uci.edu!ucivax!ucla-cs!twinsun!eggert From: eggert@twinsun.com (Paul Eggert) Newsgroups: comp.std.c Subject: Re: A question about tentative definitions Message-ID: <1991Mar5.200127.13306@twinsun.com> Date: 5 Mar 91 20:01:27 GMT References: <4218@lupine.NCD.COM> Sender: usenet@twinsun.com Organization: Twin Sun, Inc Lines: 40 Nntp-Posting-Host: ata