multiple definitions of identifiers with external linkage

Doug Gwyn gwyn at smoke.BRL.MIL
Fri Dec 1 11:26:04 AEST 1989


In article <58 at looney.twinsun.com> eggert at twinsun.com (Paul Eggert) writes:
>Doug Gwyn writes:
>>My suggestion is to generate a warning (not an official diagnostic) for
>>the second definition within a translation unit, and generate code for
>>only the first definition.
>Does this suggestion mean that the following strictly conforming program with
>two translation units should link correctly, albeit perhaps with warnings?
[omitted to save space]
>Won't most linkers flatly refuse to link this program
>because F is defined twice?

Oops.  Your argument is evidence that multiple external definitions
for the same identifier could not have been the Committee's intent
(since that linker model is the most commonly encountered one).
Therefore the lack of a clear prohibition against multiple definitions
(amongst the entire set of modules constituting a program, not just
confined to a single translation unit) must really have been an
oversight.  In fact, I recall something like that constraint in
earlier drafts, so it probably got lost in the editing that occurred
in this area in response to public review comments on external linkage.

One can still fall back on the ANDIPS and the obvious model of an
object/function as having only one definition implied by phraseology
scattered throughout the Standard to back the "no more than one
definition" interpretation.  However, this one really does need to
receive an official X3J11 interpretation ruling, since it potentially
impacts implementations in a major way.  (Having to support multiple
external definitions would require linker changes in many environments,
and that was definitely not the committee's intention.)



More information about the Comp.std.c mailing list