[RFC PATCH]: Define "bool" as _Bool when bootstrapping with gcc >= 4.4

Uros Bizjak ubizjak@gmail.com
Tue Sep 21 19:30:00 GMT 2010


On Tue, Sep 21, 2010 at 8:33 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> On Tue, Sep 21, 2010 at 11:29 AM, Uros Bizjak <ubizjak@gmail.com> wrote:
>> Hello!
>>
>> Attached patch defines bool as _Bool when bootstrapping (or compiling
>> with gcc >= 4.4).
>>
>> 2010-09-21  Uros Bizjak  <ubizjak@gmail.com>
>>
>>        * system.h (bool): Define as _Bool for gcc >= 4.4.
>>        (BOOL_BITFILED): Ditto.
>
> I think one issue is that libcpp needs to make sure it has the same
> definition for bool also.

Hm, indeed. I have started bootstrap on x86_64-pc-linux-gnu with the
attached patch (that copies relevant parts of gcc/system.h to
libgcc/system.h).

Uros.
-------------- next part --------------
Index: gcc/system.h
===================================================================
--- gcc/system.h	(revision 164480)
+++ gcc/system.h	(working copy)
@@ -621,29 +621,29 @@
    This must be after all inclusion of system headers, as some of
    them will mess us up.  */
 
-#undef TRUE
-#undef FALSE
+#ifndef __cplusplus
+# undef bool
 
-#ifdef __cplusplus
-  /* Obsolete.  */
-# define TRUE true
-# define FALSE false
-#else /* !__cplusplus */
-# undef bool
+# if GCC_VERSION >= 4004
+#  define bool _Bool
+#  define BOOL_BITFIELD _Bool
+# else
+#  define bool unsigned char
+/* Some compilers do not allow the use of unsigned char in bitfields.  */
+#  define BOOL_BITFIELD unsigned int
+# endif
+
 # undef true
 # undef false
-
-# define bool unsigned char
 # define true 1
 # define false 0
-
-  /* Obsolete.  */
-# define TRUE true
-# define FALSE false
 #endif /* !__cplusplus */
 
-/* Some compilers do not allow the use of unsigned char in bitfields.  */
-#define BOOL_BITFIELD unsigned int
+/* Obsolete.  */
+#undef TRUE
+#undef FALSE
+#define TRUE true
+#define FALSE false
 
 /* As the last action in this file, we poison the identifiers that
    shouldn't be used.  Note, luckily gcc-3.0's token-based integrated
Index: libcpp/system.h
===================================================================
--- libcpp/system.h	(revision 164480)
+++ libcpp/system.h	(working copy)
@@ -379,24 +379,34 @@
 
 /* Provide a fake boolean type.  We make no attempt to use the
    C99 _Bool, as it may not be available in the bootstrap compiler,
-   and even if it is, it is liable to be buggy.  
+   and even if it is, it is liable to be buggy.
    This must be after all inclusion of system headers, as some of
    them will mess us up.  */
-#undef bool
-#undef true
-#undef false
-#undef TRUE
-#undef FALSE
 
 #ifndef __cplusplus
-#define bool unsigned char
-#endif
-#define true 1
-#define false 0
+# undef bool
 
+# if GCC_VERSION >= 4004
+#  define bool _Bool
+#  define BOOL_BITFIELD _Bool
+# else
+#  define bool unsigned char
 /* Some compilers do not allow the use of unsigned char in bitfields.  */
-#define BOOL_BITFIELD unsigned int
+#  define BOOL_BITFIELD unsigned int
+# endif
 
+# undef true
+# undef false
+# define true 1
+# define false 0
+#endif /* !__cplusplus */
+
+/* Obsolete.  */
+#undef TRUE
+#undef FALSE
+#define TRUE true
+#define FALSE false
+
 /* Poison identifiers we do not want to use.  */
 #if (GCC_VERSION >= 3000)
 #undef calloc


More information about the Gcc-patches mailing list