I am writing a program and I would really prefer to write in C++, however, I'm required to include a C header that redefines bool:
# define false 0
# define true 1
typedef int bool;
The obvious solution would be to edit the header to say:
#ifndef __cplusplus
# define false 0
# define true 1
typedef int bool;
#endif
but, alas, since the library is read-only I cannot.
Is there a way I can tell gcc to ignore this typedef? Or, can I write most functions in C++ and then make a C wrapper for the two? Or, should I suck it up and write the thing in C?
<stdbool.h>
, you can just#define
the appropriate tag it has to say it's already done its work. If it's like C,__bool_true_false_are_defined
– Kayo<stdbool.h>
should have its own c++ guards already – District