What are the candidate types of Boolean values in C? Why is it not a standard type? Should I use # define or enum to define true and false values? C language does not provide a standard boolean type, because selecting such a type involves the best ProgramSpace/time compromise decided by members. (Using int may be faster, while using char may save more data space. However, if the int type needs to be converted repeatedly, the small type may also generate larger or slower Code.)
You can use the # define or enumeration constant to define true/false. Use any of the following forms
# Define true 1 # define Yes 1 # define false 0 # define no 0 Enum bool {false, true}; Enum bool {No, yes };
Or directly use 1 and 0, as long as they are consistent in the same program or project. If your debugger displays the name of an enumerated constant while viewing the variable, it may be better to use enumeration.
Some people prefer this definition.
# Define true (1 = 1) # define false (! True)
Or define a ''secondary" macro like this.
# Define istrue (E) (e )! = 0)
But this is not helpful.