Mail Archives: djgpp/1996/04/07/01:44:26
On Fri, 5 Apr 1996, Vladislav Panferov wrote:
> I did remember either, but still the executable size for "Hello world!" program
> is 32,768 bytes with "stdio.h" and 101,888 bytes with "iostream.h" (compiled with
> "gcc -o hello.exe -O2 -s hello.c" and "gcc -o hello.exe -O2 -s hello.cpp -liostr" resp.)
These figures are meaningless! You don't judge any serious compiler and
library by looking at the ``Hello world'' programs! What you see is the
overhead of the DJGPP startup code, and not much else. That startup code
has a tremendous amount of functionality, which you only can dream about
with other 32-bit compilers. For instance, the filename globbing code is
inside (so you can say ``hello foo/.../[a-c]*.[ch]'' and have the program
get the list of all the C files and headers which begin with a, b or c, in
the entire directory tree under `foo').
The DJGPP library has provisions to reduce the above overhead in those
programs that don't need that functionality. If your program doesn't
accept command-line arguments, and doesn't need to get environment
variables from DJGPP.ENV, you can slash its size by about 20KB by defining
a couple of empty functions; see the C library on-line docs for the
details.
> Does this mean that it's impossible to get an executable smaller than ~100k when
> using "iostream"?
IMHO, anybody who writes such programs in C++ (and not in assembly, where
they belong), deserves this. (And btw, how do other C++ compilers compare
with that figure?)
- Raw text -