|
|
|
|
|
by andrewcooke
4674 days ago
|
|
but this - and other examples here - seem unfair, in that they are blaming _Bool for working correctly (consistently, logically) in cases where people were previously doing dumb things. if you rely on something called "bool" being 0x02 you're going to have a bad time. that's hardly C99's fault. your last line of code is what i would write, effectively, if i needed to compare booleans. it seems to me that _Bool is an improvement because, pre-C99, if i forgot the !! dance somewhere, i likely had a bug. with _Bool things just work. (disclaimer, as with other reply here - still trying to get a grasp on this, so may be saying something stupid myself). |
|
It's also worth considering in context that a lot of the code which will run into problems with these small differences is low level OS/driver code that often deals with a lot of bit flags and bit manipulation in general. When your trying to fit a web server into 3800 _bytes_ of ram on an 8 bit microcontroller, 'doing dumb things' becomes 'being inventive'.