Windows: How big is a BOOL?
boolean, c, types, windows
Solution
int is officially "an integral type that is larger than or equal to the size of type short int, and shorter than or equal to the size of type long." It can be any size, and is implementation specific.
It is 4 bytes (32 bits), on Microsoft's current compiler implementation (this is compiler specific, not platform specific). You can see this on the Fundamental Types (C++) page of MSDN (near the bottom).
Sizes of Fundamental Types
Type Size
======================= =========
int, unsigned int 4 bytes
Problem
How big (in bits) is a Windows BOOL data type? Microsoft defines the BOOL data type as: ``` BOOL Boolean variable (should be TRUE or FALSE). This type is declared in WinDef.h as follows: typedef int BOOL; ``` Which converts my question into: How big (in bits) is an int data type? Edit: In before K&R. Edit 2: Something to think about Pretend we're creating a typed programming language, and compiler. You have a type that represents something logically being True or False. If your compiler can also link to Windows DLLs, and you want to call an API that requires a BOOL data type, what data type from your language would you pass/return? In order to interop with the Windows BOOL data type, you have to know how large a BOOL is. The question gets converted to how big an int is. But that's a C/C++ int, not the Integer data type in our pretend language. So i need to either find, or create, a data-type that is the same size as an int. Note: In my original question i'm not creating a compiler. i'm calling Windows from a language that isn't C/C++, so i need to find a data type that is the same size as what Windows expects.