I recently came across new use of static
keyword.
What does static
mean here?
void fun(int some_array[static 7]);
EDIT : can someone give an example where this can be useful?
The standard says in 6.7.6.3:
A declaration of a parameter as ‘‘array of type’’ shall be adjusted to ‘‘qualified pointer to type’’, where the type qualifiers (if any) are those specified within the [ and ] of the array type derivation. If the keyword static also appears within the [ and ] of the array type derivation, then for each call to the function, the value of the corresponding actual argument shall provide access to the first element of an array with at least as many elements as specified by the size expression.
It's a feature introduced in C99. So there you have it: some_array
must be at least 7 elements long.
As they say, there can't be a new standard without a new usage for the keyword static
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With