build: enforce C11 as minimum compiler standard - #617
Conversation
Replace obsolete AC_PROG_CC_C99 with AC_PROG_CC (which auto-selects the
newest available standard: C17 on GCC 8+, C11 on GCC 4.9-7) and add an
AC_COMPILE_IFELSE gate that aborts configure if __STDC_VERSION__ < 201112L.
Makes C11 or newer a hard build requirement in line with the project coding
guidelines ("C11 recommended, C99 acceptable") and enables use of _Static_assert,
_Noreturn, and inline functions without preprocessor guards.
|
works on Ubuntu 26.04 |
XV02
left a comment
There was a problem hiding this comment.
Thanks for your work on this change. First of all a discussion should be opened about making C11 the minimum compiler standard, that hasn't been discussed yet so please open an Issue first with this topic so other contributors can be part of said decision.
Also, even if the community decides to continue with the standard change, there's a comment for this change.
| dnl | ||
| dnl Check that compiler supports C11 or newer standard | ||
| dnl | ||
| AC_COMPILE_IFELSE( | ||
| [AC_LANG_PROGRAM([[ | ||
| #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 201112L | ||
| # error C11 or newer required | ||
| #endif | ||
| ]])], | ||
| [], | ||
| [AC_MSG_ERROR([C11 or newer compiler required (GCC >= 4.9, Clang >= 3.3)])] | ||
| ) |
There was a problem hiding this comment.
AC_PROG_CC_C99 checks and sets -std flag to use C99 version. So we should reproduce that functionality, this code snippet just checks the default version of C used, doesn't actually probe if the compiler is capable of using C11 standard, and also doesn't set the required flag. I'm aware the flag AC_PROG_CC_C11 exists but this breaks compilation on certain systems. Another approach for actually probing capability and setting the flag should be used.
Replace obsolete AC_PROG_CC_C99 with AC_PROG_CC (which auto-selects the newest available standard: C17 on GCC 8+, C11 on GCC 4.9-7) and add an AC_COMPILE_IFELSE gate that aborts configure if STDC_VERSION < 201112L.
Description
Makes C11 or newer a hard build requirement in line with the project coding guidelines ("C11 recommended, C99 acceptable") and enables use of _Static_assert, _Noreturn, and inline functions without preprocessor guards.
Type of change
Checklist: