diff options
author | Bruno Haible <bruno@clisp.org> | 2022-09-24 23:42:44 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2022-09-25 00:46:37 +0200 |
commit | 2eb78f0716542854209a35d7ea5bd2d38ef32582 (patch) | |
tree | 74077a937e14daa11e244377d505dac114a7d80e /m4/c-bool.m4 | |
parent | 699f559a3d30e7e0c8e20d546e25f2743f2569d1 (diff) | |
download | gnulib-2eb78f0716542854209a35d7ea5bd2d38ef32582.tar.gz |
stdbool: Don't #include a gnulib-generated stdbool.h from config.h.
* m4/c-bool.m4 (gl_C_BOOL): Check for stdbool.h and for _Bool. If
stdbool.h does not exist, don't #include <stdbool.h> but instead put the
substitute code into config.h.
Diffstat (limited to 'm4/c-bool.m4')
-rw-r--r-- | m4/c-bool.m4 | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/m4/c-bool.m4 b/m4/c-bool.m4 index 67c2cf2621..129981d2f7 100644 --- a/m4/c-bool.m4 +++ b/m4/c-bool.m4 @@ -22,6 +22,10 @@ AC_DEFUN([gl_C_BOOL], [Define to 1 if bool, true and false work as per C2023.]) fi + AC_CHECK_HEADERS_ONCE([stdbool.h]) + AC_REQUIRE([AC_CHECK_HEADER_STDBOOL]) + AC_DEFINE_UNQUOTED([HAVE__BOOL],[$HAVE__BOOL]) + dnl The "zz" puts this toward config.h's end, to avoid potential dnl collisions with other definitions. dnl If 'bool', 'true' and 'false' do not work, arrange for them to work. @@ -32,7 +36,43 @@ AC_DEFUN([gl_C_BOOL], AH_VERBATIM([zzbool], [#ifndef HAVE_C_BOOL # if !defined __cplusplus && !defined __bool_true_false_are_defined -# include <stdbool.h> +# if HAVE_STDBOOL_H +# include <stdbool.h> +# else + /* Substitute. Keep consistent with gnulib/lib/stdbool.in.h. */ +# ifndef _GL_STDBOOL_H +# define _GL_STDBOOL_H +# ifdef __cplusplus +# if !defined _MSC_VER +# define _Bool bool +# define bool bool +# endif +# else +# if !defined __GNUC__ +# define _Bool signed char +# else +# if !HAVE__BOOL +typedef enum { _Bool_must_promote_to_int = -1, false = 0, true = 1 } _Bool; +# endif +# endif +# define bool _Bool +# endif +# ifdef __cplusplus +# if !defined _MSC_VER +# define false false +# define true true +# endif +# if defined __SUNPRO_CC && true != 1 +# undef true +# define true (!false) +# endif +# else +# define false 0 +# define true 1 +# endif +# define __bool_true_false_are_defined 1 +# endif /* _GL_STDBOOL_H */ +# endif # endif # if !true # define true (!false) |