stdbool.h should be compatible with C++

Martin Buchholz martin@xemacs.org
Sun Dec 5 02:06:00 GMT 1999


The following program:

----------------------------
#include <stdbool.h>
bool foo;
----------------------------

could, with a little care, compile under C and C++.  It fails under
gcc-2.95.2 c++.

Of course, portable programs cannot do this - they must autoconfiscate
themselves.

FYI, I am placing the following obvious autoconfiscated program
fragment into the Public Domain:

#ifndef __cplusplus
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else /* Implement <stdbool.h> ourselves */
#undef	bool
#undef	true
#undef	false
#undef	__bool_true_false_are_defined

#define	bool emacs_bool
#define	true  1
#define	false 0
#define	__bool_true_false_are_defined 1
typedef unsigned int emacs_bool;
#endif /* ! HAVE_STDBOOL_H */
#endif /* ! C++ */


More information about the Gcc-bugs mailing list