From 16a62c7ab3846a1996624cccc0e16dd4adb5deb0 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Thu, 26 Feb 2015 13:02:04 -0300 Subject: [PATCH] shared: avoid checking for __STDC_VERSION__ 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 | 8 ++++++++ shared/macro.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 3ba65cc..ecf3e83 100644 --- a/configure.ac +++ b/configure.ac @@ -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- ##################################################################### diff --git a/shared/macro.h b/shared/macro.h index a081a49..4fc5405 100644 --- a/shared/macro.h +++ b/shared/macro.h @@ -63,7 +63,7 @@ /* Define C11 noreturn without 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)) -- 2.39.2