One year ago I would agree about the bool/false/true case. But, nowadays I sin and use uint8_t, 0 and 1 for every boolean, since I use a lot of fwrite() and fread() in my codebase and I want 100% guarantee that I’m writing and reading an unsigned byte to/from file, on any platform, and I don’t want to create an intermediate variable every time. I’d rather write a good variable name to convey the meaning, and know it’s a boolean without looking.
One year ago I would agree about the bool/false/true case. But, nowadays I sin and use
uint8_t
,0
and1
for every boolean, since I use a lot offwrite()
andfread()
in my codebase and I want 100% guarantee that I’m writing and reading an unsigned byte to/from file, on any platform, and I don’t want to create an intermediate variable every time. I’d rather write a good variable name to convey the meaning, and know it’s a boolean without looking.Using
0
and1
is a sensible and idiomatic way to represent C boolean constants, nothing wrong with that.Just don’t
#define True 1
;)