]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
use -std=c23 if it's available, otherwise use -std=c11
authorAlan T. DeKok <aland@freeradius.org>
Thu, 23 Oct 2025 09:51:31 +0000 (11:51 +0200)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 24 Oct 2025 15:05:02 +0000 (17:05 +0200)
the "configure" script was not yet updated

configure.ac
m4/ax_cc.m4

index 754d4c52f1cb43aaa97797886ef2a28bb3b1110e..f2cd044e892ac58d3bba015aca78dde1927c2ddb 100644 (file)
@@ -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 #
index 88b69875e570c404c4a752e2fe6955ddac0046b3..8e712562cb33e4f802f4143dec7da2a04ce1295f 100644 (file)
@@ -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 #