KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I've written a collection of data structures and functions in C, some of which use the _Bool data type. When I began, the project was going to be pure C. Now I am investigating using a C++ based GUI tool kit and have made the backend code into a library. However, when compiling the C++ GUI the following error is emitted by the compiler: ISO C++ forbids declaration of '_Bool' with no type I initially thought I could search & replace _Bool to bool and create: /* mybool.h */ #ifndef MYBOOL_H #define MYBOOL_H typedef _Bool bool; #endif /* MYBOOL_H */ and then in any headers that use _Bool #ifdef __cplusplus extern "C" { #else #include "mybool.h" #endif /* rest of header... */ Until I realized this would be compiling the library with one boolean (C _Bool) data type, and linking against the library using another (C++ bool). Practically, this might not matter, but theoretically, it probably does (there might be some obscure system somewhere which doing so like this causes the universe to turn inside out). I suppose I could just use an int and use 0 for false and 1 for true, and typedef it with something like typedef int mybool , but it seems unattractive. Is there a better/idiomatic/standard way to do this?
Tags (comma-separated)
Save Edits
Cancel