Valhalla Legends Archive

Programming => General Programming => C/C++ Programming => Topic started by: iago on December 11, 2003, 01:21 PM

Title: BOOL vs. bool
Post by: iago on December 11, 2003, 01:21 PM
I noticed that, when I'm using inline assembly, bool functions and BOOL functions don't behave the same.  Can anybody share some light on this?

Thanks!
-iago

[edit] I know that BOOL is typedeffed as an int, but bool seems to be native.  But how are they different?
Title: Re:BOOL vs. bool
Post by: Zakath on December 11, 2003, 01:27 PM
bool is a built-in data type.

(http://www.valhallalegends.com/zakath/BOOL.png)

sizeof(bool) == 1
sizeof(BOOL) == 4

That should account for most differences, I'd think.
Title: Re:BOOL vs. bool
Post by: iago on December 11, 2003, 01:51 PM
ah, so bool only counts as 1?  I figured they had left it as 4 for alignment.  

Thanks :)
Title: Re:BOOL vs. bool
Post by: Skywing on December 12, 2003, 01:30 AM
Quote from: iago on December 11, 2003, 01:51 PM
ah, so bool only counts as 1?  I figured they had left it as 4 for alignment.  

Thanks :)
It may be padded to 4 bytes depending on how and where it's used.  In the case of function return values, though, typically only al will be set for x86.
Title: Re:BOOL vs. bool
Post by: Yoni on December 12, 2003, 05:27 AM
Also, bool can be either true (1) or false (0), it cannot receive any other values. BOOL can receive any long/doubleword value and this is sometimes sloppily done in Win32 API. Examples: GetMessage return value, and the return value of WM_CTLCOLORSTATIC and its friends.