Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!amdahl!pacbell!att!cbnewsc!tjr From: tjr@cbnewsc.ATT.COM (thomas.j.roberts) Newsgroups: comp.sys.ibm.pc Subject: Re: Turbo C links in everything in obj's Message-ID: <319@cbnewsc.ATT.COM> Date: 24 Mar 89 15:03:20 GMT References: <7337@phoenix.Princeton.EDU> Organization: AT&T Bell Laboratories Lines: 21 > In article <1065@ptolemy.arc.nasa.gov> raymond@ptolemy.arc.nasa.gov > (Eric A. Raymond) writes: >>It appears that the linker in Turbo C (2.0) links in everything you >>have in your .objs independent of whether the code is actually used. >>For instance, if you have a file with the following fn's in it >> main, a, b, c, d, e >>and main does not call any of a, b, c, d, or e, the linker still >>includes the objects for a, b, c, d, and e. This is, of course, required by the definition of the C language; it is NOT a disadvantage of Turbo C. In C, files are always linked in in their entirety. tlink also links in a .obj that is named on the command line, whether or not ANY of its functions are called elsewhere; I presume that is to avoid an extra pass during linking to specifically check for an un-referenced .obj file. The ONLY way to avoid linking a,b,c,d,e in the example above is to split them out into another file (beware of static variables with file scope). Tom Roberts att!ihnet!tjr