Note: I have seen In C, why can't a const variable be used as an array size initializer? already, but this doesn't quite answer my question (or I am not understanding it fully).
This works:
int main() {
const long COUNT = 1048106;
int nums[COUNT];
return 0;
}
This crashes:
int main() {
const long COUNT = 1048106000;
int nums[COUNT];
return 0;
}
I have read that this is actually an inappropriate use of const
to begin with (since it means read-only, not evaluated at compile time).
So I am happy to use #define
or whatnot instead, but still, it bothers me why this works for some lengths but not but not any higher.