[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H
From: |
Paul Eggert |
Subject: |
Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H |
Date: |
Fri, 04 Feb 2011 20:59:00 -0800 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7 |
On 02/01/2011 07:58 AM, Eric Blake wrote:
> I agree 100% that the two macros must be split and that gnulib should
> not use AC_HEADER_STDBOOL, but I don't (yet) see any convincing reason
> either for or against marking the autoconf macro obsolete
OK, thanks, I installed the following patches to autoconf and to gnulib,
respectively. It implements this more-conservative suggestion.
>From 81b5c5b9fafdcf0b6ba51728ff76d679d35ece13 Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 4 Feb 2011 20:38:07 -0800
Subject: [PATCH] autoconf: new macro AC_HEADER_CHECK_STDBOOL
* NEWS: Document this.
* doc/autoconf.texi (Particular Headers): Likewise.
In example, don't assume a 'system.h' exists.
* lib/autoconf/headers.m4 (AC_CHECK_HEADER_STDBOOL): New macro.
Use it with AN_IDENTIFIER, since it's less heavyweight.
Reindent to match gnulib, since that's a bit nicer.
(AC_HEADER_STDBOOL): Reimplement in terms of it.
---
ChangeLog | 11 ++++
NEWS | 3 +
doc/autoconf.texi | 33 +++++++++--
lib/autoconf/headers.m4 | 135 +++++++++++++++++++++++++----------------------
4 files changed, 113 insertions(+), 69 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b36aab1..6d65401 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2011-02-04 Paul Eggert <address@hidden>
+
+ autoconf: new macro AC_HEADER_CHECK_STDBOOL
+ * NEWS: Document this.
+ * doc/autoconf.texi (Particular Headers): Likewise.
+ In example, don't assume a 'system.h' exists.
+ * lib/autoconf/headers.m4 (AC_CHECK_HEADER_STDBOOL): New macro.
+ Use it with AN_IDENTIFIER, since it's less heavyweight.
+ Reindent to match gnulib, since that's a bit nicer.
+ (AC_HEADER_STDBOOL): Reimplement in terms of it.
+
2011-01-29 Jim Warhol <address@hidden> (tiny change)
* doc/autoconf.texi (Introduction): Fix typo.
diff --git a/NEWS b/NEWS
index d00c312..c485f22 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,9 @@ GNU Autoconf NEWS - User visible changes.
** AS_LITERAL_IF again treats '=' as a literal. Regression introduced in
2.66.
+** Macros
+
+- New macro AC_HEADER_CHECK_STDBOOL.
* Noteworthy changes in release 2.68 (2010-09-22) [stable]
Released by Eric Blake, based on git versions 2.67.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index b1ccb1a..6ad657e 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -5811,6 +5811,21 @@ AC_CHECK_HEADERS([X11/extensions/scrnsaver.h], [], [],
These macros check for particular system header files---whether they
exist, and in some cases whether they declare certain symbols.
address@hidden AC_CHECK_HEADER_STDBOOL
address@hidden
address@hidden HAVE__BOOL
address@hidden
address@hidden header_stdbool_h
+Check whether @file{stdbool.h} exists and conforms to C99, and cache the
+result in the @code{ac_cv_header_stdbool_h} variable. If the type
address@hidden is defined, define @code{HAVE__BOOL} to 1.
+
+This macro is intended for use by Gnulib (@pxref{Gnulib}) and other
+packages that supply a substitute @file{stdbool.h} on platforms lacking
+a conforming one. The @code{AC_HEADER_STDBOOL} macro is better for code
+that explicitly checks for @file{stdbool.h}.
address@hidden defmac
+
@defmac AC_HEADER_ASSERT
@acindex{HEADER_ASSERT}
@cvindex NDEBUG
@@ -5937,14 +5952,14 @@ New programs need not use this macro.
@cvindex HAVE_STDBOOL_H
@cvindex HAVE__BOOL
@hdrindex{stdbool.h}
address@hidden
@caindex header_stdbool_h
If @file{stdbool.h} exists and conforms to C99, define
@code{HAVE_STDBOOL_H} to 1; if the type @code{_Bool} is defined, define
@code{HAVE__BOOL} to 1. To fulfill the C99 requirements, your
address@hidden could contain the following code:
+program could contain the following code:
address@hidden
address@hidden
address@hidden
#ifdef HAVE_STDBOOL_H
# include <stdbool.h>
#else
@@ -5960,14 +5975,20 @@ typedef bool _Bool;
# define true 1
# define __bool_true_false_are_defined 1
#endif
address@hidden verbatim
address@hidden group
address@hidden example
Alternatively you can use the @samp{stdbool} package of Gnulib
-(@pxref{Gnulib}); it packages the above code into a replacement header
-and contains a few other bells and whistles.
+(@pxref{Gnulib}). It simplifies your code so that it can say just
address@hidden <stdbool.h>}, and it adds support for less-common
+platforms.
This macro caches its result in the @code{ac_cv_header_stdbool_h}
variable.
+
+This macro differs from @code{AC_CHECK_HEADER_STDBOOL} only in that it
+defines @code{HAVE_STDBOOL_H} whereas @code{AC_CHECK_HEADER_STDBOOL}
+does not.
@end defmac
@anchor{AC_HEADER_STDC}
diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
index 75bdfef..4b02832 100644
--- a/lib/autoconf/headers.m4
+++ b/lib/autoconf/headers.m4
@@ -591,72 +591,81 @@ fi
])# AC_HEADER_STAT
-# AC_HEADER_STDBOOL
+# AC_CHECK_HEADER_STDBOOL
# -----------------
# Check for stdbool.h that conforms to C99.
-AN_IDENTIFIER([bool], [AC_HEADER_STDBOOL])
-AN_IDENTIFIER([true], [AC_HEADER_STDBOOL])
-AN_IDENTIFIER([false],[AC_HEADER_STDBOOL])
-AC_DEFUN([AC_HEADER_STDBOOL],
-[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
- [ac_cv_header_stdbool_h],
- [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
- [[
-#include <stdbool.h>
-#ifndef bool
- "error: bool is not defined"
-#endif
-#ifndef false
- "error: false is not defined"
-#endif
-#if false
- "error: false is not 0"
-#endif
-#ifndef true
- "error: true is not defined"
-#endif
-#if true != 1
- "error: true is not 1"
-#endif
-#ifndef __bool_true_false_are_defined
- "error: __bool_true_false_are_defined is not defined"
-#endif
+AN_IDENTIFIER([bool], [AC_CHECK_HEADER_STDBOOL])
+AN_IDENTIFIER([true], [AC_CHECK_HEADER_STDBOOL])
+AN_IDENTIFIER([false],[AC_CHECK_HEADER_STDBOOL])
+AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
+ [AC_CACHE_CHECK([for stdbool.h that conforms to C99],
+ [ac_cv_header_stdbool_h],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[
+ #include <stdbool.h>
+ #ifndef bool
+ "error: bool is not defined"
+ #endif
+ #ifndef false
+ "error: false is not defined"
+ #endif
+ #if false
+ "error: false is not 0"
+ #endif
+ #ifndef true
+ "error: true is not defined"
+ #endif
+ #if true != 1
+ "error: true is not 1"
+ #endif
+ #ifndef __bool_true_false_are_defined
+ "error: __bool_true_false_are_defined is not defined"
+ #endif
+
+ struct s { _Bool s: 1; _Bool t; } s;
+
+ char a[true == 1 ? 1 : -1];
+ char b[false == 0 ? 1 : -1];
+ char c[__bool_true_false_are_defined == 1 ? 1 : -1];
+ char d[(bool) 0.5 == true ? 1 : -1];
+ /* See body of main program for 'e'. */
+ char f[(_Bool) 0.0 == false ? 1 : -1];
+ char g[true];
+ char h[sizeof (_Bool)];
+ char i[sizeof s.t];
+ enum { j = false, k = true, l = false * true, m = true * 256 };
+ /* The following fails for
+ HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
+ _Bool n[m];
+ char o[sizeof n == m * sizeof n[0] ? 1 : -1];
+ char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
+ /* Catch a bug in an HP-UX C compiler. See
+ http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
+
http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
+ */
+ _Bool q = true;
+ _Bool *pq = &q;
+ ]],
+ [[
+ bool e = &s;
+ *pq |= q;
+ *pq |= ! q;
+ /* Refer to every declared value, to avoid compiler
optimizations. */
+ return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k +
!!l
+ + !m + !n + !o + !p + !q + !pq);
+ ]])],
+ [ac_cv_header_stdbool_h=yes],
+ [ac_cv_header_stdbool_h=no])])
+ AC_CHECK_TYPES([_Bool])
+])# AC_CHECK_HEADER_STDBOOL
+
- struct s { _Bool s: 1; _Bool t; } s;
-
- char a[true == 1 ? 1 : -1];
- char b[false == 0 ? 1 : -1];
- char c[__bool_true_false_are_defined == 1 ? 1 : -1];
- char d[(bool) 0.5 == true ? 1 : -1];
- /* See body of main program for 'e'. */
- char f[(_Bool) 0.0 == false ? 1 : -1];
- char g[true];
- char h[sizeof (_Bool)];
- char i[sizeof s.t];
- enum { j = false, k = true, l = false * true, m = true * 256 };
- /* The following fails for
- HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */
- _Bool n[m];
- char o[sizeof n == m * sizeof n[0] ? 1 : -1];
- char p[-1 - (_Bool) 0 < 0 && -1 - (bool) 0 < 0 ? 1 : -1];
- /* Catch a bug in an HP-UX C compiler. See
- http://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html
- http://lists.gnu.org/archive/html/bug-coreutils/2005-11/msg00161.html
- */
- _Bool q = true;
- _Bool *pq = &q;
- ]],
- [[
- bool e = &s;
- *pq |= q;
- *pq |= ! q;
- /* Refer to every declared value, to avoid compiler optimizations. */
- return (!a + !b + !c + !d + !e + !f + !g + !h + !i + !!j + !k + !!l
- + !m + !n + !o + !p + !q + !pq);
- ]])],
- [ac_cv_header_stdbool_h=yes],
- [ac_cv_header_stdbool_h=no])])
-AC_CHECK_TYPES([_Bool])
+# AC_HEADER_STDBOOL
+# -----------------
+# Define HAVE_STDBOOL_H if tdbool.h that conforms to C99.
+AC_DEFUN([AC_HEADER_STDBOOL],
+[AC_CHECK_HEADER_STDBOOL
if test $ac_cv_header_stdbool_h = yes; then
AC_DEFINE(HAVE_STDBOOL_H, 1, [Define to 1 if stdbool.h conforms to C99.])
fi
--
1.7.4
>From f0f4bea6c4efd2b5a1e058beb7dce5a9342647cd Mon Sep 17 00:00:00 2001
From: Paul Eggert <address@hidden>
Date: Fri, 4 Feb 2011 20:54:58 -0800
Subject: [PATCH] stdbool: do not define HAVE_STDBOOL_H
* m4/stdbool.m4 (AC_CHECK_HEADER_STDBOOL): Renamed from
AC_HEADER_STDBOOL. All uses changed. Do not define
HAVE_STDBOOL_H, as gnulib does not need this. This change is
imported from the latest Autoconf git. It was motivated by Emacs,
which uses gnulib but does not need HAVE_STDBOOL_H.
---
ChangeLog | 9 +++++++++
m4/stdbool.m4 | 14 +++++---------
2 files changed, 14 insertions(+), 9 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f2e20c1..fd79da1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-02-04 Paul Eggert <address@hidden>
+
+ stdbool: do not define HAVE_STDBOOL_H
+ * m4/stdbool.m4 (AC_CHECK_HEADER_STDBOOL): Renamed from
+ AC_HEADER_STDBOOL. All uses changed. Do not define
+ HAVE_STDBOOL_H, as gnulib does not need this. This change is
+ imported from the latest Autoconf git. It was motivated by Emacs,
+ which uses gnulib but does not need HAVE_STDBOOL_H.
+
2011-02-04 Bruno Haible <address@hidden>
wcsnrtombs: Prepare for new module wwcsnrtombs.
diff --git a/m4/stdbool.m4 b/m4/stdbool.m4
index df10486..838cf0f 100644
--- a/m4/stdbool.m4
+++ b/m4/stdbool.m4
@@ -5,13 +5,13 @@ dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
-#serial 3
+#serial 4
# Prepare for substituting <stdbool.h> if it is not supported.
AC_DEFUN([AM_STDBOOL_H],
[
- AC_REQUIRE([AC_HEADER_STDBOOL])
+ AC_REQUIRE([AC_CHECK_HEADER_STDBOOL])
# Define two additional variables used in the Makefile substitution.
@@ -33,11 +33,9 @@ AC_DEFUN([AM_STDBOOL_H],
# AM_STDBOOL_H will be renamed to gl_STDBOOL_H in the future.
AC_DEFUN([gl_STDBOOL_H], [AM_STDBOOL_H])
-# This version of the macro is needed in autoconf <= 2.67. Autoconf has
-# it built in since 2.60, but we want the tweaks from the 2.68 version
-# to avoid rejecting xlc and clang due to relying on extensions.
+# This version of the macro is needed in autoconf <= 2.68.
-AC_DEFUN([AC_HEADER_STDBOOL],
+AC_DEFUN([AC_CHECK_HEADER_STDBOOL],
[AC_CACHE_CHECK([for stdbool.h that conforms to C99],
[ac_cv_header_stdbool_h],
[AC_COMPILE_IFELSE(
@@ -98,6 +96,4 @@ AC_DEFUN([AC_HEADER_STDBOOL],
[ac_cv_header_stdbool_h=yes],
[ac_cv_header_stdbool_h=no])])
AC_CHECK_TYPES([_Bool])
- if test $ac_cv_header_stdbool_h = yes; then
- AC_DEFINE([HAVE_STDBOOL_H], [1], [Define to 1 if stdbool.h conforms to
C99.])
- fi])
+])
--
1.7.4
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Simon Josefsson, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Ralf Corsepius, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Eric Blake, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Ralf Corsepius, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Eric Blake, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Paul Eggert, 2011/02/01
- Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H,
Paul Eggert <=
Re: HAVE_STDBOOL_H, AC_HEADER_STDBOOL, and AM_STDBOOL_H, Russ Allbery, 2011/02/01