diff --git a/share/libc/stdbool.h b/share/libc/stdbool.h index c7eee3eeab20337d22d1555b2a406fd51a78275f..3ff8ac91166a50e313bf1880cfec6332ae11ffd8 100644 --- a/share/libc/stdbool.h +++ b/share/libc/stdbool.h @@ -22,8 +22,11 @@ #ifndef __FC_STDBOOL #define __FC_STDBOOL +// In C++, bool, true and false are native values +#ifndef __cplusplus #define bool _Bool #define true 1 #define false 0 +#endif #define __bool_true_false_are_defined 1 #endif diff --git a/tests/libc/oracle/stdbool_as_cpp.res.oracle b/tests/libc/oracle/stdbool_as_cpp.res.oracle new file mode 100644 index 0000000000000000000000000000000000000000..52caed5026184bf7c523aee46060d04cea94ed12 --- /dev/null +++ b/tests/libc/oracle/stdbool_as_cpp.res.oracle @@ -0,0 +1,10 @@ +[kernel] Parsing tests/libc/stdbool_as_cpp.c (with preprocessing) +/* Generated by Frama-C */ +int main(void) +{ + int __retres; + __retres = 0; + return __retres; +} + + diff --git a/tests/libc/stdbool_as_cpp.c b/tests/libc/stdbool_as_cpp.c new file mode 100644 index 0000000000000000000000000000000000000000..13e7bd6f68b767ce547902f72392b9a19cbff61a --- /dev/null +++ b/tests/libc/stdbool_as_cpp.c @@ -0,0 +1,16 @@ +/* run.config* +OPT: -print +*/ +// announce that we are a non-conforming C++ compiler +#define __cplusplus 1L +#include <stdbool.h> +#ifdef bool +#error bool should not be defined in C++ mode +#endif +#ifdef true +#error true should not be defined in C++ mode +#endif +#ifdef false +#error false should not be defined in C++ mode +#endif +int main() { return 0; }