delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/06/13/01:05:04

From: mert0407 AT sable DOT ox DOT ac DOT uk (George Foot)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Optimization and header info
Date: 12 Jun 1997 16:28:22 GMT
Organization: Oxford University, England
Lines: 36
Message-ID: <5np836$488@news.ox.ac.uk>
References: <339FF9C7 DOT 48F8 AT xnet DOT com>
NNTP-Posting-Host: sable.ox.ac.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

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 -


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