I\'ve seen definitions in C
#define TRUE (1==1)
#define FALSE (!TRUE)
Is this necessary? What\'s the benefit over simply defining TRUE as
This approach will use the actual boolean
type (and resolve to true
and false
) if the compiler supports it. (specifically, C++)
However, it would be better to check whether C++ is in use (via the __cplusplus
macro) and actually use true
and false
.
In a C compiler, this is equivalent to 0
and 1
.
(note that removing the parentheses will break that due to order of operations)