Paul Eggert wrote: > > Thus, it's best to avoid such a situation. This holds not only for > > <stdalign.h> but also for <stdbool.h>. For <assert.h> on the other hand > > I think the trouble is limited, because <assert.h> always exists among the > > system header files. > > These days stdbool.h falls into pretty much the same category as > assert.h. As far as I know, every platform currently supported by Gnulib > that doesn't have a working bool builtin (and thus will include > stdbool.h) has a stdbool.h that should work well enough for all but the > most contrarian of uses. So I suggest leaving stdbool.h alone. That way, > we'll have better luck with Autoconf and AC_C_BOOL.
Indeed, the platforms lacking <stdbool.h> are: - HP-UX 11, IRIX 6.5 — both not among our target platforms any more, - Solaris 10 with cc — but here support can be added just by tweaking $CC. See <https://gitlab.com/ghwiki/gnow-how/-/wikis/Platforms/Configuration> So, I'm reverting most of yesterday's change and putting in a #error instead, to tell the user. On Solaris 10, this error looks like this: "../config.h", line 536: #error: "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC." On HP-UX and IRIX, it would look like this: ../config.h: error: "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'." > stdalign.h is more of a problem as it was introduced in C11 and Gnulib > doesn't require C11 yet, so we will need a fix along the lines of what > you suggested, though I wish the code duplication could be avoided. The code duplication could be avoided by letting gnulib-tool include lib/stdalign.in.h into the shipped copy of m4/stdalign.m4. I'm still thinking about how to achieve this in a way that is not a special-case hack but more useful in general. 2022-09-25 Bruno Haible <br...@clisp.org> stdbool: Mostly revert last patch. * m4/c-bool.m4 (gl_C_BOOL): If stdbool.h does not exist, just err out. * modules/stdbool (Files): Remove m4/stdbool.m4. diff --git a/ChangeLog b/ChangeLog index 1c54eabb49..24553445f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,16 @@ +2022-09-25 Bruno Haible <br...@clisp.org> + + stdbool: Mostly revert last patch. + * m4/c-bool.m4 (gl_C_BOOL): If stdbool.h does not exist, just err out. + * modules/stdbool (Files): Remove m4/stdbool.m4. + 2022-09-24 Bruno Haible <br...@clisp.org> 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. + * modules/stdbool (Files): Add m4/stdbool.m4. 2022-09-24 Bruno Haible <br...@clisp.org> diff --git a/m4/c-bool.m4 b/m4/c-bool.m4 index 129981d2f7..bb109b7796 100644 --- a/m4/c-bool.m4 +++ b/m4/c-bool.m4 @@ -23,8 +23,6 @@ AC_DEFUN([gl_C_BOOL], 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. @@ -39,39 +37,11 @@ AC_DEFUN([gl_C_BOOL], # 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 */ +# if defined __SUNPRO_C +# error "<stdbool.h> is not usable with this configuration. To make it usable, add -D_STDC_C99= to $CC." +# else +# error "<stdbool.h> does not exist on this platform. Use gnulib module 'stdbool-c99' instead of gnulib module 'stdbool'." +# endif # endif # endif # if !true diff --git a/modules/stdbool b/modules/stdbool index 664df5e0f8..2e771a2336 100644 --- a/modules/stdbool +++ b/modules/stdbool @@ -3,7 +3,6 @@ A bool that is like C23. Files: m4/c-bool.m4 -m4/stdbool.m4 Depends-on: c99