On 2025-10-06 16:50, Antonin Décimo wrote:

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.

"VLA_STATIC" is still too long. Also, the name is confusing, because it's a macro for declaring pointer objects that have automatic (not static) storage duration. (This is a beef I have with the keyword "static" in the first place, of course.) And these objects are not VLAs; they merely have a VLA type.

Admittedly "ATIC", while short, is not a great name either. How about "ATLEAST" instead? Although it's longer, it's more self-explanatory. Code would look like this:

  int strcmp (char const a[ATLEAST 1], char const b[ATLEAST 1]);

and this is more self-explanatory than "static" is.

Note that the semantics changed between C17 (6.10.8.3):
Yes, I suppose ATLEAST can mean "static" for C11 and later, the empty string earlier (roughly speaking, depending on what compilers actually support).

In contrast, __STDC_NO_VLA__ is kinda tricky and I suppose should be a separate issue.

An issue related to ATLEAST, though, is that in the GNU world people typically use the nonnull attribute instead, e.g.:

  int strcmp (char const *, char const *)
    __attribute__ ((__nonnull__ (1,2)));

An advantage of this approach is that it's more flexible and powerful, for example:

  void *memcpy (void *, void const *, size_t)
    __attribute__ ((__nonnull_if_nonzero__ (1, 3),
                    __nonnull_if_nonzero__ (2, 3)));

which is something that the "static" syntax cannot say.

So I'm not sure that Autoconf should be pushing only C23-style "static", without also saying, "hey, GCC has something better".

Reply via email to