ARM Technical Support Knowledge Articles

Maximum size of arrays for C/C++ compilers

Applies to: ARM Developer Suite (ADS), DS-5, RealView Developer Kit (RVDK) for OKI, RealView Developer Kit (RVDK) for ST, RealView Developer Kit for XScale (RVXDK), RealView Development Suite (RVDS)

Answer

In ADS 1.1 and earlier, there is a limit of 8MB on the maximum size of objects, due to internal compiler implementation limits. If this is exceeded, the compilers will report "Error: C2429E: structure or array too large", as the following example shows:

/*test.c*/
char arr[10000000000];
...
/*end*/

Command line: armcc -c test.c

"test.c", line 1: Error: C2429E: structure or array too large

To create larger arrays, you can use malloc() instead. If you cannot use malloc(), then you can define the array as a ZI area in an assembler file using SPACE, for example:

         AREA mymem, DATA, NOINIT, ALIGN=2
array    SPACE 100000000 ; define 100000000 bytes zeroed store
         END

Then declare the array in a header file like: extern int array[];

The SPACE directive reserves a zeroed block of memory. % is a synonym for SPACE.

This limit is raised to 256MB in ADS 1.2, and to 4GB in RVCT 2.x and later, which is due to the maximum value of an integer. In RVCT 2.x and later, the equivalent error message is: "Error: #95: array is too large".

Article last edited on: 2011-08-22 11:25:40

Rate this article

[Bad]
|
|
[Good]
Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential