multiple definitions of identifiers with external linkage
Paul Eggert
eggert at twinsun.com
Thu Nov 30 06:09:40 AEST 1989
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. Inter-translation unit multiple definitions
are handled the usual way (typically by the linker). That technique
should be standard conforming.
Does this suggestion mean that the following strictly conforming program with
two translation units should link correctly, albeit perhaps with warnings?
x.c:
int F(){return 0;}
int G(int i){return i;}
y.c:
int F(){return 1;}
int G(int);
int main() {return G(0);}
Won't most linkers flatly refuse to link this program
because F is defined twice?
More information about the Comp.std.c
mailing list