Historically, BOOL
used as the type anything-not-0 = TRUE. For example, the dialog procedure returned BOOL
, which could contain a lot of information. Signed below from Microsoft Documentation :
BOOL CALLBACK DlgProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
The result of the signature and the function combined several problems, which is why in the modern API instead
INT_PTR CALLBACK DialogProc( _In_ HWND hwndDlg, _In_ UINT uMsg, _In_ WPARAM wParam, _In_ LPARAM lParam );
This newfangled declaration should remain compatible with the old. This means that INT_PTR
and BOOL
must be the same size. This means that in 32-bit programming, BOOL
is 32 bits.
In the general case, since BOOL
can be any value, not just 0 and 1, it is a very difficult idea to compare a BOOL
with TRUE
. And although it works to compare it with FALSE
, it is also generally bad practice, because it can easily give people the impression that a comparison with TRUE
will be fine. In addition, because it is completely optional.
By the way, in the Windows API there are more logical types, in particular VARIANT_BOOL
, which is 16 bits, and where the logical TRUE is represented as all 1 bit patterns, i.e. -1
as the sign value of & hellip;
This is an additional reason why it is not practical to compare directly with a logical FALSE or TRUE.