Mail Archives: djgpp/1997/06/13/01:05:04
machine4u (slaisch AT xnet DOT com) wrote:
: gcc hello.c -s -o hello.exe (generates 36K executable)
: gxx hello.cpp -s -o hello.exe (generates 103K executable)
: Am I doing something wrong? Why are they so huge?
1) Executable size is pretty much irrelevant nowadays - except for floppy
disk storage.
2) You're using a sledgehammer to crack a nut; your DJGPP programs are
doing all sorts of fancy things (find a DPMI server, switch to protected
mode, glob the command line, blah blah blah) just to print a string. When
you write longer programs, all this startup code is not duplicated at all.
Don't be alarmed at the sizes you've given.
3) You haven't tried compressing the program; get mlp*b.zip (I forget
which directory it's in) and try running the DJP program on your
executables.
The optimisation which the compiler can do (specify -O on the commandline,
possibly followed by a number) is aimed at speeding up the execution of
your code, which is generally far more important than size on disk.
: One more thing, if I were developing a game or something where I would
: not need stdio.h or iostream.h, what would I sacrifice besides the
: standard console output? printf/scanf/cout/cin?
For an exhaustive list, read the relevant .h files :). Don't sacrifice
anything; if you need something, #include the header file. Also try typing
(at the DOS prompt): info libc f stdio. This will bring up an approximate
list of what stdio.h provides, with descriptions of each.
--
George Foot <mert0407 AT sable DOT ox DOT ac DOT uk>
Merton College, Oxford
- Raw text -