delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/21/20:02:56

Date: Sun, 21 Jul 1996 19:43:38 -0400 (EDT)
From: "Mike A. Harris" <mharris AT blackwidow DOT saultc DOT on DOT ca>
To: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
cc: Bruce Foley <brucef AT central DOT co DOT nz>, djgpp AT delorie DOT com
Subject: Re: How do I create my own libraries ?
In-Reply-To: <Pine.SUN.3.91.960721110909.5526R-100000@is>
Message-ID: <Pine.LNX.3.91.960721193703.10120A-100000@blackwidow.saultc.on.ca>
MIME-Version: 1.0

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019