"variable-size type declared" error for const sized array

Bahadir Balban krupiyer@gmail.com
Sun Aug 28 16:56:00 GMT 2005


Hi,

I want to use a const int to specify the size of an array but get the
error: "variable-size type declared outside of any function".

If I use a literal (e.g. 5) for the array size then compilation is fine. 

Is there a gcc flag that would allow me to use const variables to
define array sizes? I see no difference between the two apart from the
fact that a variable eliminates the cryptic magic number. (Yes a
#define would solve it, but I don't want to use it.)

Thanks,
Bahadir



More information about the Gcc-help mailing list