I know, that bool is used in C++, while BOOL is a Microsoft specific type that is defined as an int.
My code is using BOOL as it was made for Windows to start with, but I'm trying to keep things the same way without changing my code from BOOL to bool, when I'm going port it to Mac.
Could something like this work?
typedef int8_t _Bool;
typedef _Bool (BOOL);
static const BOOL False = 0;
static const BOOL True = 1;
If yes, is there a better way and why?
If not, then why and what should I do instead?
I don't see why a good IDE couldn't make a global change from BOOL to bool. I'd prefer having greater portability. I wouldn't like the typedefs, because it'd be harder to read.
The biggest problem that I see with rolling your own bool is that template specifications that recognize bool will not recognize BOOL, going the default route. Specifically, vector<bool> uses a different code base to save space by packing bits in a representation of the vector; using vector<BOOL> will result in a representation that is roughly eight times larger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With