Variably modified array at file scope

遇到这个问题好几次了,记录下:

const int N = 100005;
int stack1[N];

错误信息:

error: variably modified 'stack1' at file scope

错误原因:

The reason for this warning is that const in c doesn't mean constant. It means "read only". So the value is stored at a memory address and could potentially be changed by machine code.


解决办法:

#define N  100005
int stack1[N];


你可能感兴趣的:(Variably modified array at file scope)