Compressing C programs

Mike Percy grimlok at hubcap.clemson.edu
Tue Jan 9 05:30:10 AEST 1990


>From article <1990Jan7.161841.6470 at druid.uucp>, by darcy at druid.uucp (D'Arcy J.M. Cain):
> In article <18731 at netnews.upenn.edu> ferris at eniac.seas.upenn.edu.UUCP (Richard T. Ferris) writes:
>>I am interested in learning how to reduce the size of my TurboC
>>programs.  The .exe files are 13K even for very simple programs.
>>Could someone send me some suggested references?  Thanks.
>>
> 
> I have the following flags (among others that don't have to do with code
> optimization) in my TURBOC.CFG file:
> 
> -v-              Source level debugging off
> -Z               Optimize register usage
> -r               register variables
> 

If you can avoid using printf, do so. Printf drags in a large routine.
Many times you can use puts rather than printf.  In my experience, puts
is not only smaller than printf, but faster.
 
Another thing in TurboC to avoid if possible is dragging in the floating
point libraries when you don't need them.  If you have no floats or
doubles, you don't have to include the floating point emulator.  If you
do have floats, and don't have an 80x87, you are stuck with the
emulator. Turn off floating point with -f-.

Be careful when using the -Z flag, as it can cause _very_
difficult-to-track-down bugs. 

You might also try -O (optimize for size).  Make sure that you haven't
set -v and -y.  The keep executables small, use -v- and -y-.



-- 

'I just couldn't convince the voters that Dukakis was Greek for
"Bubba".' -- Lloyd Benson explaining why the Democrats didn't carry
Texas



More information about the Comp.lang.c mailing list