]> Savannah Git Hosting - gnulib.git/commitdiff
stdbool: omit ‘#undef true’
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 18 Sep 2022 18:26:36 +0000 (11:26 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 18 Sep 2022 18:27:17 +0000 (11:27 -0700)
This is mostly just simplification.
* m4/c-bool.m4 (gl_C_BOOL): Test all preprocessors when
!HAVE_C_BOOL, not merely __SUNPRO_CC.  Use the slightly
more-elegant ‘!true’ instead of ‘true == 1’; this shouldn’t matter
in practice and if it does matter we want to know about it anyway.
Remove an unnecessary ‘#undef true’ that is simply commented out
by ‘configure’; again, if true is already #defined to be 0 the
system is so messed up we want to know about it anyway.

ChangeLog
m4/c-bool.m4

index 87c370bd043394fd09c93aa5a7e420718f5ed1db..77862ed6237e1a31984b0ec5ee406975e7f18776 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2022-09-18  Paul Eggert  <eggert@cs.ucla.edu>
+
+       stdbool: omit ‘#undef true’
+       This is mostly just simplification.
+       * m4/c-bool.m4 (gl_C_BOOL): Test all preprocessors when
+       !HAVE_C_BOOL, not merely __SUNPRO_CC.  Use the slightly
+       more-elegant ‘!true’ instead of ‘true == 1’; this shouldn’t matter
+       in practice and if it does matter we want to know about it anyway.
+       Remove an unnecessary ‘#undef true’ that is simply commented out
+       by ‘configure’; again, if true is already #defined to be 0 the
+       system is so messed up we want to know about it anyway.
+
 2022-09-18  Bruno Haible  <bruno@clisp.org>
 
        stdbool: Ensure that 'true' can be used in the preprocessor.
index 980de611b9ef23dd7276c3974f89e58bdb0e974a..67c2cf26215c2fba53039ae6d50e90e166ab9582 100644 (file)
@@ -24,19 +24,17 @@ AC_DEFUN([gl_C_BOOL],
 
   dnl The "zz" puts this toward config.h's end, to avoid potential
   dnl collisions with other definitions.
-  dnl In C++ mode 'bool', 'true', 'false' are keywords and thus we don't need
-  dnl <stdbool.h>.  But in C mode, we do.
-  dnl Check __bool_true_false_are_defined to avoid re-including <stdbool.h>.
-  dnl In Sun C++ 5.11 (Solaris Studio 12.2) and older, 'true' as a preprocessor
-  dnl expression evaluates to 0, not 1.  Fix this by overriding 'true'.  Note
-  dnl that the replacement has to be of type 'bool'.
+  dnl If 'bool', 'true' and 'false' do not work, arrange for them to work.
+  dnl In C, this means including <stdbool.h> if it is not already included.
+  dnl However, if the preprocessor mistakenly treats 'true' as 0,
+  dnl define it to a bool expression equal to 1; this is needed in
+  dnl Sun C++ 5.11 (Oracle Solaris Studio 12.2, 2010) and older.
   AH_VERBATIM([zzbool],
-[#if !defined HAVE_C_BOOL
+[#ifndef HAVE_C_BOOL
 # if !defined __cplusplus && !defined __bool_true_false_are_defined
 #  include <stdbool.h>
 # endif
-# if defined __SUNPRO_CC && true != 1
-#  undef true
+# if !true
 #  define true (!false)
 # endif
 #endif])