Why not defining BOOL as an enum like in :
enum BOOL {FALSE, TRUE};
Is there any reason why BOOL must be specified explicitly as int (or any other integral type)?
From Raymond Chen's blog article on this topic:
BOOL vs. VARIANT_BOOL vs. BOOLEAN vs. bool
Still more ways of saying the same thing. Why so many?
Because each was invented by different people at different times to solve different problems.
BOOLis the oldest one. Its definition is simply
typedef int BOOL;The C programming language uses "int" as its boolean type, and Windows 1.0 was written back when C was the cool language for systems programming.
The vast majority of the Win32 API is still designed for C to this day, so that it is compatible with a large variety of programming languages that are compatible with C.
Enums have portability issues across compilers, related to differences in byte size and bit representation. Besides, enum wasn't added to C until ANSI C in 1989 (aka C98), which was after three releases of Windows (1.0 in 1985, 2.0 in 1987, and 2.1 in 1988), and enums are effectively equivalent to integers anyway.
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