libraries may hide porting problems
wsmith at m.cs.uiuc.edu
wsmith at m.cs.uiuc.edu
Wed Aug 31 05:30:00 AEST 1988
This problem with the BSD linker can cause portability problems for
programs that use programmer created libraries.
Description:
In the BSD C compiler may not complain of multiply defined functions
while in other C compilers will fail to link the same program.
If the only data needed by the linker from a module is a variable
in BSS, multiply defined functions in that same module will be
ignored.
Repeat-By:
Create two files, one.c two.c
one.c:
extern int a;
main()
{
printf("%d\n",a);
}
four() { }
two.c:
int a;
four() { }
If the program is compiled with "cc -o aprog one.c two.c", _four is
reported as multiply defined. However, if the program is compiled with
"cc -c one.c two.c
ar r alib.a two.o
ranlib alib.a
cc -o aprog one.o alib.a" no error will be reported (under BSD).
With other compilers on other operating systems, _four will be multiply
defined in both cases. However, if the first line of two.c is changed to
"int a = 7;", the BSD C compiler will report _four as multiply defined in
both cases. Linking with a library should be equivalent to linking the
individual modules in the library that are needed. In this problematic
case, the equivalence is broken.
Fix: ???
Bill Smith wsmith at cs.uiuc.edu uiucdcs!wsmith
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list