Mail Archives: djgpp/1996/07/21/20:02:56
On Sun, 21 Jul 1996, Eli Zaretskii wrote:
>
> On Sat, 20 Jul 1996, Bruce Foley wrote:
>
> > BTW, I was wondering, when a program uses a function
> > from a library, does the whole library get linked, or just
> > the function you are calling?
>
> Only the function(s) you call are linked. Otherwise, every DJGPP program
> will be at least the size of libc.a, which is 530KBytes.
This poses an interesting question. In the past, when coding libraries
for Borland C 3.1, I put all of the functions in a single .c module. Then
put the resulting obj into a .lib. After discussing this on the FIDO C_ECHO
I found out that, at least with Borland, when you put more than one function
into a C source module, and then put the module into a lib, or even just use
the obj, that when you include that lib or obj into a program, ALL functions
are linked into the code wether or not they are actually used in the code.
This posed an interesting learning experience. So ever since then, when
coding libs, I've used one function per module. This prevents unneeded
code from bloating executables.
Is this also true of DJGPP? What about other compilers? Should one always
code LIBs as one function per module source files?
Mike A. Harris - The Computer Doctor - Computer Consulting
Internet, Modems, DOS, Windows, Virus Removal, Memory Management, etc.
mharris AT blackwidow DOT saultc DOT on DOT ca Bus.: (705)946-0896
http://blackwidow.saultc.on.ca/~mharris Home: (705)946-3963
- Raw text -