March 28th, 2011

Why did Win32 define BOOL as a signed int instead of an unsigned int?

Igor Levicki wants somebody from Microsoft to explain why BOOL was defined as a signed int instead of an unsigned int. You don’t need to work for Microsoft to figure this out. All the information you need is publically available.

Quoting from K&R Classic, which was the operative C standards document at the time Windows was being developed:

7.6 Relational Operators

The [relational operators] all yield 0 if the specified relation is false and 1 if it is true. The type of the result is int.

Win32 defined BOOL as synonymous with int because Brian and Dennis said so. If you want to know why Brian and Dennis decided to have the result of relational operators be signed instead of unsigned, you’ll have to ask them.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.