Mail Archives: djgpp/1997/10/09/05:51:43
On Wed, 8 Oct 1997, Salvador Eduardo Tropea (SET) wrote:
> Bad news:
> GCC doesn't support big arrays with initialization, like this:
>
> char XXX[100000]={ 1,2,....
> ...
> ... 99999 };
>
> The compiler will crash or if you have luck (like I have) it will
> report out of virtual memory. Seems that gcc uses MUCH more memory
> for this that what we can think. For example: 300000 elements needs
> more than 40Mb.
Are you sure? Can you post a short program that shows this problem?
Testing with a program that I used (see below) indicates that it takes
cc1 about 10MB to compile it. But I never had any crashes or "out of
memory" messages.
#include <stdio.h>
#include <stdlib.h>
unsigned xxx[100000] = {
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, /* 9,999 lines like this */
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
....
....
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
};
int main (void)
{
return printf ("%d\n", xxx[rand() % 3] + xxx[rand() % 4]);
}
- Raw text -