this is the way you tell C what is the size of array.
void f(int n, int a[n]) {
}this is the way you tell C what is the size of array.
void f(int n, int a[n]) {
} void f(int n, int a[]) {
}
Why? So that you can write void f(int n, int m, int a[n][m]) {
}
which declares a 2-dimensional array parameter. In that case, the "m" is used to compute the position in the array for a 2D array. The "m" doesn't do anything.
This is equivalent to writing void f(int n, int m, int a[][m]) {
}
This is C's minimal multidimensional array support, known by few and used by fewer.Over a decade ago, I proposed that sizes in parameters should be checkable and readable I worked out how to make it work.[1] But I didn't have time for the politics of C standards.
[1] http://animats.com/papers/languages/safearraysforc43.pdf
The major difference is when the array is multi-dimensional. If you don't have VLAs then you can only set the inner dimensions at compile time, or alternatively use pointer-based work-arounds.
Even in the case of one-dimensional arrays, a compiler or a static analyzer can take advantage of the VLA size information to insert run-time checks in debug mode, or to perform compile-time checks.
Parameters like `const double b[static restrict 10]` for at least 10 long and doesn't alias other parameters.
Syntactically this is pretty weird.