delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/07/31/01:36:53

Date: Wed, 31 Jul 1996 08:32:38 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Peter Berdeklis <peter AT atmosp DOT physics DOT utoronto DOT ca>
Cc: djgpp AT delorie DOT com
Subject: Re: Flat Memory Questions
In-Reply-To: <Pine.SGI.3.91.960730103019.8069A-100000@chinook.physics.utoronto.ca>
Message-Id: <Pine.SUN.3.91.960731082742.1793I-100000@is>
Mime-Version: 1.0

On Tue, 30 Jul 1996, Peter Berdeklis wrote:

> What does the array being static have to do with using C++?  Any static 
> variable must have memory space preallocated, either in the initialized 
> data segment (=1 Mb bloat) or in the uninitialized segment (no bloat).  
> What am I missing Charles?

You are missing the explanation in section 8.14 of the DJGPP FAQ list 
(available as v2/faq201b.zip from the same place you get DJGPP):

  **Q*: It seems that declaring a large `static' array has an 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 GNU C 
  Compiler docs in "GNU C Compiler Manual", or point your Web browser to 
  http://www.delorie.com/gnu/docs/gcc/gcc_11.html#SEC14.

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

- Raw text -


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