]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
shared: avoid checking for __STDC_VERSION__
authorLucas De Marchi <lucas.demarchi@intel.com>
Thu, 26 Feb 2015 16:02:04 +0000 (13:02 -0300)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 26 Feb 2015 16:15:14 +0000 (13:15 -0300)
Since we pass -std=gnu99 to the compiler __STDC_VERSION__ is defined to
199901. Even in this case we can use _Noreturn. Delegate the testing to
the configure phase with a compile test.

In future we want to stop using AC_PROG_CC_99 and start using the new
AC_PROG_CC from autoconf 2.70, which tries to choose the most recent
standard.

configure.ac
shared/macro.h

index 3ba65ccaf01d3a6f877dcb10d53b947a00a3f6af..ecf3e8386bb36f23f8154b9eadadef45b2c22785 100644 (file)
@@ -65,6 +65,14 @@ AC_COMPILE_IFELSE(
         AC_MSG_RESULT([yes])],
        [AC_MSG_RESULT([no])])
 
+AC_MSG_CHECKING([whether _Noreturn is supported])
+AC_COMPILE_IFELSE(
+       [AC_LANG_SOURCE([[_Noreturn int foo(void) { exit(0); }]])],
+        [AC_DEFINE([HAVE_NORETURN], [1], [Define if _Noreturn is available])
+        AC_MSG_RESULT([yes])],
+       [AC_MSG_RESULT([no])])
+
+
 #####################################################################
 # --with-
 #####################################################################
index a081a495df9b7c1f12ecb845d3e0775e4f88c6ab..4fc54059519f535a209199af7e6b6f34797e38d6 100644 (file)
@@ -63,7 +63,7 @@
 /* Define C11 noreturn without <stdnoreturn.h> and even on older gcc
  * compiler versions */
 #ifndef noreturn
-#if __STDC_VERSION__ >= 201112L
+#if defined(HAVE_NORETURN)
 #define noreturn _Noreturn
 #else
 #define noreturn __attribute__((noreturn))