As far as I can see, there are three ways to use Booleans in C:
- with the bool type, from <stdbool.h> then using true and false
- defining using preprocessor
#define FALSE 0 ... #define TRUE !(FALSE)
- Just to use constants directly, i.e. 1 and 0
Are there other methods I missed? What are the pros and cons of the different methods?
I suppose the fastest would be number 3, 2 is more easily readable still (although bitwise negation will slightly add to overhead), and 1 is most readable not compatible with all compilers.