[comp.lang.c] EXE file size

gwyn@smoke.brl.mil (Doug Gwyn) (11/12/90)

In article <4302@sactoh0.SAC.CA.US> jak@sactoh0.SAC.CA.US (Jay A. Konigsberg) writes:
>I have wondered the same thing. Mainly, why are C exectuables so large.
>foo.c       11
>foo.o      256 
>foo       4815

The executable contains a run-time startoff module (crt0.o), plus some
library functions needed by crt0.o, such as exit().  Clever C library
implementations are able to arrange that the stdio overhead normally
needed to support exit() is not linked in when stdio functions are not
invoked directly by the application; otherwise, there would also be
all the static _iob structs and the code for fclose(), fflush(), etc.
crt0.o also is responsible for collecting environment variables and
program arguments so that they can be passed to main() etc.

gwyn@smoke.brl.mil (Doug Gwyn) (11/12/90)

In article <71185@iuvax.cs.indiana.edu> herrj@silver.ucs.indiana.edu (Jonathan R. Herr) writes:
>Might the C files be larger due to the #include'd files? When you
>include these, isn't the WHOLE file included?

For Christ's sake, standard header files define macros and declare library
externs; they do NOT define library externs.  That occurs only when the
extern definitions are linked into the executable from the library, which
they will not be if no use has been made of them.

Besides, in the posted example there were no #includes.