-
Bool
Hi all
A book I'm learning Direct3D from is causing more problems than it's solving so far!
I am coming across a data type called "BOOL" - in capitals, not to be confused with the standard "bool" syntax. The only data that it seems to be given is "TRUE" AND "FALSE" - again with capitals.
The book does not provide any header that might contain a BOOL class, and seems to expect the reader not to be surprised by this new data type. It seems to treat the data as an array as it checks the data using the following syntax:
It's obviously checking the letter in the "TRUE" or "FALSE" data provided by the user (although it's not clear why it's checking buf[1] instead of buf[0] ).
I was not surprised when Visual Express 2008 came back with: "syntax error: identifier 'BOOL'. However I can't change this data to a standard "bool" data type without majorly screwing with other code (it's a big program and I don't really have to space to explain why this this is!).
I was wondering if anyone has come across this before? If so please could you explain where "BOOL" comes from and how it works? Bonus points if you can also explain why the above if statement would check buf[1] instead of buf[0]!
Thanks a lot :-)
-
BOOL is a "Windows" data type for a boolean, since C90 does not actually define a boolean type, and Windows API is built for C90.
BOOL is merely a typedef for int. Likewise, TRUE and FALSE is 1 and 0 respectively.
If you include windows.h, you'll likely get this typedef for free. Otherwise you can create them manually or change to bool/true/false.
-
Thanks for that, I thought Windows API was already being included but I'll check when I get a second. :-)