Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: programming quesion, about executable size.

Author: Heiner Marxen

Date: 10:01:30 06/26/00

Go up one level in this thread


On June 25, 2000 at 20:21:41, Antonio Dieguez wrote:

>First, am sorry my ignorance.
>
>I added to my program hash tables recently.
>
>The entries are like this:
>
>
>const static int capacidadhash=524288; // 7 megas para la hashtable.
>
>struct
>{
>
>long id;
>short prof_tipov; // tiene prof*10+tipov
>short eval;
>short recomxy; // tiene recx*100+recy
>
>} hashtable[capacidadhash];
>
>
>am compiling with gcc and my question is why this make the executable of my
>program be 7 mb of size?
>
>thanks.

I have experienced a similar effect with a C-compiler of HP-UX (not yet
with gcc), when I made the array static.
Here is a quote from the Chest sources:

/*
 * Some declarations of large, implicitly zero-initialized arrays are
 * prefixed by "I0static" (instead of static).  This handle can be used
 * to stop some annoying compilers from converting them into explicitly
 * initialized data (which creates huge binaries).
 */
#ifndef  I0static                       /* BSS: 0-inited data */
# define I0static       static
#endif

... and sometimes override that by an earlier:
#define I0static        /*empty*/

You may have a similar problem.  Play around with static/extern
and with explicit/implicit initialization.
[ A single zero is enough to initialize all to zeros: ...[...] ={ 0 }; ]

If you cannot solve it that way... you can use malloc/calloc to allocate
at run time.  Is probably more flexible, anyhow.

Heiner



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.