[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: use of __STDC_VERSION__ > foo in config.h
From: |
Paul Eggert |
Subject: |
Re: use of __STDC_VERSION__ > foo in config.h |
Date: |
Thu, 10 May 2012 09:08:24 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:11.0) Gecko/20120329 Thunderbird/11.0.1 |
The general idea that config.h should work with -Wundef is OK
<http://lists.gnu.org/archive/html/bug-gnulib/2011-11/msg00308.html>
but I see a couple of problems with the proposed patch.
First, the logic is wrong, as it assumes that when
__STDC_VERSION__ is not defined then the compiler supports C11,
whereas a better heuristic (these days, anyway) is that the compiler
does not support C11. Second, there shouldn't be a need to alter
the code if it's an Apple compiler, since the problem has been
reported only for GCC. So I pushed this smaller patch instead:
_Noreturn: port config.h to gcc -Wundef
* m4/gnulib-common.m4 (gl_COMMON_BODY): Check that __STDC_VERSION__ is
defined before using it, for gcc -Wundef. Reported by Akim Demaille in
<http://lists.gnu.org/archive/html/bug-gnulib/2012-05/msg00147.html>.
diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4
index ab3c43d..d62b767 100644
--- a/m4/gnulib-common.m4
+++ b/m4/gnulib-common.m4
@@ -14,7 +14,8 @@ AC_DEFUN([gl_COMMON], [
AC_DEFUN([gl_COMMON_BODY], [
AH_VERBATIM([_Noreturn],
[/* The _Noreturn keyword of C11. */
-#if !defined _Noreturn && __STDC_VERSION__ < 201112
+#if ! (defined _Noreturn \
+ || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__))
# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \
|| 0x5110 <= __SUNPRO_C)
# define _Noreturn __attribute__ ((__noreturn__))