Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Senor Cuete

macrumors 6502
Original poster
Nov 9, 2011
449
32
I have a project with this C code:

Code:
const unsigned long ARRAY_SIZE = 1000000;

unsigned long array[ARRAY_SIZE];

XCode posts a strange warning:

Variable length array folded to constant array as an extension

There is no warning if I remove the const declaration from the ARRAY_SIZE declaration.

What does this mean?
 
It means the compiler realized ARRAY_SIZE is a compile-time constant (which is clearly what you mean) vis-a-vis a runtime constant.

Did you per-chance get this code from c++ (where the constant is both compile- and runtime)?

if the warning bothers you you can use a
Code:
#define ARRAY_SIZE 1000000
which leaves the c compiler no room for interpretation.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.