I am reading about the C-coding style for embedded systems and I found the following statement:
Do not use stdbool.h library. Use 1 or 0 for true or false respectively
This statement was written in the following source: https://github.com/MaJerle/c-code-style
However, there is no explanation why to use it or any advantage/ disadvantage in adopting such style.
I would like to know if there is any advantage in using 1 or 0 instead of true or false.
What can be said about stdbool.h
specifically:
1
/0
would therefore be backwards compatibility with C90.stdbool.h
unnecessary (but not formally deprecated yet), because in C23 bool
, true
and false
are finally made proper keywords. _Bool
is still available too.Also the coding style has the following rules:
Comments starting with // are not allowed.
This also suggests that C90 compatibility is required, because that's the only reason why you would not allow such comments (they were introduced in C99).
Do not declare variable after first executable statement
Similarly, this is also required for C90 compatibility, which otherwise doesn't make any sense.
So I would conclude that a lot of these rules were added for C90 compatibility, or otherwise there is no making sense of them.