arrayscgcc

What is the maximum size of a static array that can be declared in GCC?


How is it determined ? Does this depend on the compiler/Architecture/Host system ?

Example:

int array[0x8000000000000000]; 

For this line GCC outputs the following on a x86_64 bit system:

Error "size of array 'array' is too large".

Solution

  • By static array, I assume, you mean a fixed length array (statically allocated, like int array[SIZE], not dynamically allocated). Array size limit should depend on the scope of the array declared.