-
C99
I am using gcc 4.4.3 version
i am getting a compile error :- error: variable-sized object may not be initialized
Code:
double dev_dp[num_app][2] = {{0.30 ,400},
{0.33 ,200},
{0.25 ,300},
{0.15 ,300}};
i know C99 supports variable sized arrays. so why am i getting this error??
-
Perhaps you forgot to enable C99 support?
-
No, I don't think that is the trouble - it seems that the GCC devs are moving toward C99 being the default behaviour. At any rate, if you do not use the std=c99 switch, but have some C99 constructs, it will not complain.
Perhaps the OP can post a little more code. It seems to me that this has to do with the array being initialised within a function.
-
No, this is because you are trying to initialize the array on the same line as you create it.
This will error:
Code:
int someArray[someVariable] = {2,3,4};
This wont error
Code:
int someArray[someVariable];
someArray[0] = 2;
// And so on