Objective-C TRUE/FALSE vs true/false

The YES and NO identifiers are considered the standard Objective-C literals for BOOL. You usually won't find YES, NO, or BOOL outside of Objective-C source code. Note that these identifiers are actually macros defined in objc/objc.h.

The true and false identifiers are standard C99 (as you noted), if you #include <stdbool.h>. Note that, since you're using Objective-C, you are probably including stdbool.h indirectly, even if you don't know it. For example, Foundation.h includes CoreFoundation.h, which includes stdbool.h. Thus it's pretty hard to compile a modern iOS or Mac app without getting true and false.

The TRUE and FALSE identifiers are not standard. They are historic baggage defined by various libraries. The libraries may have been written before the advent of C99, or written after but intended to support pre-C99 compilers, or simply written by authors ignorant of the C99 boolean literals. On the Mac, some examples of such libraries are Kerberos, XDR/RPC, and ncurses. Most importantly, the Mach kernel headers define TRUE and FALSE constants, and (as with stdbool.h) it's pretty hard to avoid these particular definitions if you're building a modern iOS or Mac app.

In all the cases I could find, TRUE is defined as 1 or (1) and FALSE is defined as 0 or (0).


All of the libraries I mentioned, and the Mach kernel, predate C99 and are thus justified in defining their own boolean constants.

Objective-C's BOOL, YES, and NO appear in Brad Cox's Object-Oriented Programming: An Evolutionary Approach from 1991, so these identifiers are also justified.