Thank you for your answer!
> > Gentle ping; this is useful for a trick from Modern C, 3rd edition,
> > from Jens Gustedt. See 5.4-2.
> > https://inria.hal.science/hal-02383654v2/file/modernC.pdf
>
> Thanks for the ping, though I'm a bit puzzled by the
> "5.4-2". Perhaps you're referring to an older edition of the book?
My apologies, the sidebar with the TOC was not in sync with the
document on my viewer. It's in Level 1. Acquaintance > Buckle up.
> Does Gustedt recommend a macro for this sort of thing?
I suppose he would recommend using a compliant compiler!
> The macro name seems pretty long, given how commonly used this would
> be for code that uses Gustedt's style. How about a shorter name like
> "ATIC", short for "Array TINIEST INDEX COUNT"? This macro name is
> short and (unlike "STATIC") is unlikely to be used in existing code.
I'm not sure... Unfortunately this is unlike
AC_C_{REGISTER,VOLATILE,INLINE} because it's only in this context that
static isn't supported. Maybe VLA_STATIC? FWIW a lookup on GitHub did
not return exact matches.
https://github.com/search?q=VLA_STATIC&type=code
For reference this is defined in C23 6.7.7.4:
> 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.
> Also, we should arrange for __STDC_NO_VLA__ to be 1 on compilers
> that don't define that macro but lack support for VLAs.
Note that the semantics changed between C17 (6.10.8.3):
> The integer constant 1, intended to indicate that the implementation
> does not support variable length arrays or variably modified types.
and C23 (6.10.10.4):
> The integer constant 1, intended to indicate that the implementation
> does not support variable length arrays with automatic storage
> duration. Parameters declared with variable length array types are
> adjusted and then define objects of automatic storage duration with
> pointer types. Thus, support for such declarations is mandatory.
The C23 semantics is the one implemented e.g., by MSVC in C99/C11/C17 modes.
I think it makes sense to always implement the C23 semantics.
-- Antonin