If I write an array of variable length as local, for example:
#include <stdio.h>
int main()
{
int i=1;
int a[i];
printf("%zu",sizeof(a));
}
It works great in the GCC compiler.
But, if I write an array of variable length as globally, for example:
#include <stdio.h>
int i=1;
int a[i];
int main()
{
printf("%zu",sizeof(a));
}
The GCC compiler then produces the following error:
prog.c:4:5: error: variably modified 'a' at file scope
int a[i];
source
share