delorie.com is funded by banner ads.
  www.delorie.com/djgpp/v2faq/faq062.html   search  

| Previous | Next | Up | Top |

8.12 C++ programs yield large .exe file

Q: It seems that declaring a large static array has the effect of bloating the program image on disk by that many bytes. Surely there is a more compact way of telling the loader to set the next N bytes of RAM to zero?


A: This only happens in C++ programs and is a (mis-)feature of GCC. You can use the -fconserve-space switch to GCC to prevent this from happening, but it also turns off the diagnostics of duplicate definitions, which, if uncaught, might cause your program to crash. Thus, this switch isn't recommended for programs which haven't been completely debugged (if there is such a creature). The -fconserve-space switch is described in the GCC docs, see the "C++ Dialect Options" section of the "GNU C Compiler Manual".

If the problems with using this switch doesn't deter you, you can even add this switch to your lib/specs file to make it permanent.


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 1998   by Eli Zaretskii     Updated Sep 1998  

Powered by Apache!

You can help support this site by visiting the advertisers that sponsor it! (only once each, though)