Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!haven!mimsy!oddjob!uxc!uxc.cso.uiuc.edu!a.cs.uiuc.edu!m.cs.uiuc.edu!wsmith From: wsmith@m.cs.uiuc.edu Newsgroups: comp.bugs.4bsd Subject: libraries may hide porting problems Message-ID: <3400002@m.cs.uiuc.edu> Date: 30 Aug 88 19:30:00 GMT Lines: 41 Nf-ID: #N:m.cs.uiuc.edu:3400002:000:1269 Nf-From: m.cs.uiuc.edu!wsmith Aug 30 14:30:00 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@cs.uiuc.edu uiucdcs!wsmith