Patch: stdbool.h should be compatible with C++
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Sun Dec 5 12:57:00 GMT 1999
> The following program:
>
> ----------------------------
> #include <stdbool.h>
> bool foo;
> ----------------------------
>
> could, with a little care, compile under C and C++.
Thanks for the proposal. Here is a patch for the mainline compiler.
1999-12-05 Martin v. Löwis <loewis@informatik.hu-berlin.de>
* ginclude/stdbool.h: Support compilation as C++.
Index: stdbool.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/ginclude/stdbool.h,v
retrieving revision 1.4
diff -u -r1.4 stdbool.h
--- stdbool.h 1999/09/23 18:02:55 1.4
+++ stdbool.h 1999/12/05 20:52:06
@@ -31,6 +31,7 @@
#ifndef _STDBOOL_H
#define _STDBOOL_H
+#ifndef __cplusplus
/* The type `_Bool' must promote to `int' or `unsigned int'. The constants
`true' and `false' must have the value 0 and 1 respectively. */
typedef enum
@@ -45,6 +46,16 @@
/* The macro `bool', which may be undefined, expands to _Bool. */
#define bool _Bool
+
+#else /* __cplusplus */
+
+/* Supporting <stdbool.h> in C++ is a GCC extension. */
+#define _Bool bool
+#define bool bool
+#define false false
+#define true true
+
+#endif /* __cplusplus */
/* Signal that all the definitions are present. */
#define __bool_true_false_are_defined 1
More information about the Gcc-patches
mailing list