Parse C99 fixed array arguments
In C, these three declarations are identical:
void foo (int arg[3]);
void foo (int arg[]);
void foo (int *arg);
The fixed size array is ignored entirely, and the compiler won't validate any argument that does not conform outside of the type; this means that it's entirely possible to use:
int a[2] = { 0, 1 };
foo (a);
without getting a warning at compile time.
In C99 it's possible (and recommended) to, instead, use the static
keyword when declaring the array argument:
void foo (int arg[static 3]);
If you do so, you'll only be able to pass an array of 3 or more elements to the foo()
function, otherwise the compiler will emit a warning. For more information: https://hamberg.no/erlend/posts/2013-02-18-static-array-indices.html
Sadly, g-ir-scanner currently chokes on a declaration that uses static
inside the square brackets, e.g.
test.h:12: syntax error, unexpected STATIC in 'const float a[static 3],' at 'static'