Why is it not possible to declare an array outside of a function with variables as size parameters in C99?
For example, consider this code snippet.
It results in an error: variably modified ‘matrix’ at file scope
compile error.
static int const height = 5;
static int const width = 5;
static int const matrix[height][width] = { ... };
int main(void){ ... }
I know that const in c doesn't mean constant. It means "read only", but I don't properly understand what implications this have. So why can't arrays get their size from read-only memory?
I know this problem can be solved using #defines
or enum
so i am more interested in an explanation as to why this is the case.