This is a C99 feature that helps with static analysis. > 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. See _Array declarators_ and _Function declarators_ from the C standard. It is not supported by MSVC: [C11: static inside array parameter square brackets](https://developercommunity.visualstudio.com/t/C11:-static-inside-array-parameter-squar/1475168). Both gcc and clang warn if `NULL` or if an array too small is passed to the function. Interestingly gcc also warns in the non-static case if an array too small is passed. cppcheck considers in both cases that the array has a fixed size and warns for out-of-bounds accesses. I'm suggesting adding an AC_C_STATIC_ARRAY_DECLARATOR macro, defined to static, or empty. I've tentatively written a macro modelled after AC_C_FLEXARRAY, attached to this mail. The name of the macro can, as it should, be bikeshedded. I'm not too sure how m4 processes the [ and ] in the description. Cheers, -- Antonin
Attachment:
0001-AC_C_STATIC_ARRAY_DECLARATOR.patch
Description: Binary data