From: Alan T. DeKok Date: Thu, 23 Oct 2025 09:51:31 +0000 (+0200) Subject: use -std=c23 if it's available, otherwise use -std=c11 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1bd7a59004d6c463937acafb3ad8bdd5fa16d619;p=thirdparty%2Ffreeradius-server.git use -std=c23 if it's available, otherwise use -std=c11 the "configure" script was not yet updated --- diff --git a/configure.ac b/configure.ac index 754d4c52f1..f2cd044e89 100644 --- a/configure.ac +++ b/configure.ac @@ -341,11 +341,16 @@ else AC_SUBST(clang_path, "") fi -AX_CC_STD_C11 -if test "x$ax_cv_cc_std_c11_flag" != x; then - CFLAGS="$CFLAGS $ax_cv_cc_std_c11_flag" +AX_CC_STD_C23 +if test "x$ax_cv_cc_std_c23_flag" != x; then + CFLAGS="$CFLAGS $ax_cv_cc_std_c23_flag" else - AC_MSG_ERROR([FreeRADIUS requires a C11 compiler]) + AX_CC_STD_C11 + if test "x$ax_cv_cc_std_c11_flag" != x; then + CFLAGS="$CFLAGS $ax_cv_cc_std_c11_flag" + else + AC_MSG_ERROR([FreeRADIUS requires a C11 compiler]) + fi fi dnl # diff --git a/m4/ax_cc.m4 b/m4/ax_cc.m4 index 88b69875e5..8e712562cb 100644 --- a/m4/ax_cc.m4 +++ b/m4/ax_cc.m4 @@ -15,6 +15,31 @@ AC_DEFUN([AX_CC_IS_CLANG],[ ]) ]) +AC_DEFUN([AX_CC_STD_C23],[ + AC_CACHE_CHECK([for the compiler flag to enable C23 support], [ax_cv_cc_std_c23_flag],[ + ax_cv_cc_std_c23_flag= + + CFLAGS_SAVED=$CFLAGS + CFLAGS="$CFLAGS -Werror -std=c23" + + AC_LANG_PUSH(C) + AC_TRY_COMPILE( + [], + [ + struct foo { + union { + int a; + int b; + }; + } bar; + ], + [ax_cv_cc_std_c23_flag="-std=c23"]) + + AC_LANG_POP + CFLAGS="$CFLAGS_SAVED" + ]) +]) + dnl # dnl # clang and gcc originally used different flags to specify c11 support dnl #