From: "Deepblade" Newsgroups: comp.os.msdos.djgpp Subject: Re: 3k lines = 4 MEG!! EXE ?? Help Date: Sat, 24 Jan 1998 13:46:47 +0200 Organization: GEM Internet Company (Pty) Ltd Lines: 43 Message-ID: <885719592.215815@diamond.gem.co.za> References: <34C4B1C1 DOT 51D2 AT netunlimited DOT net> <34C5716C DOT 541A AT cs DOT com> NNTP-Posting-Host: onyx.gem.co.za Cache-Post-Path: diamond.gem.co.za!unknown AT cpt5 DOT gem DOT co DOT za Cache-Post-Path: news.gem.co.za!unknown AT diamond DOT gem DOT co DOT za To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk >If you are using C++, then the answer is simple: gcc builds static >arrays into the executable when compiling a C++ program. If you declare >something like: > >static int global_array[1000][1000]; > >All 4 megabytes of the array will be included in the executable file. >See chapter 8.14 of the DJGPP FAQ for precise details and instructions >on how to keep this from happening. As I see it, prefixing a global array declaration with the word 'static' stops gcc from building huge files. take for example these files: // nostatic.cc char buf[1024][1024]; int main() { } and // static.cc static char buf[1024][1024]; int main() { } when compiled using: gcc -s nostatic.cc -o static gcc -s static.cc -o nostatic gives me: nostatic.exe at 1051kb static.exe at 27kb I've been using this for ages, and it has always worked for me. Is it a bad idea? I know I should probably use dynamic allocation, but I'm lazy ;-)