Skip to content

Commit

Permalink
CodingStyle: Mention our assumption about conversions to bool
Browse files Browse the repository at this point in the history
Signed-off-by: YAMAMOTO Takashi <[email protected]>
Acked-by: Ben Pfaff <[email protected]>
  • Loading branch information
yamt committed Oct 1, 2014
1 parent ee8627f commit d7fdacb
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CodingStyle
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,11 @@ C DIALECT
* bool and <stdbool.h>, but don't assume that bool or _Bool can
only take on the values 0 or 1, because this behavior can't be
simulated on C89 compilers.
Also, don't assume that a conversion to bool or _Bool follows
C99 semantics. I.e. use "(bool)(some_value != 0)" rather than
"(bool)some_value". The latter might produce unexpected results
on non-C99 environments. For example, if bool is implemented as
a typedef of char and some_value = 0x10000000.

* Designated initializers (e.g. "struct foo foo = {.a = 1};" and
"int a[] = {[2] = 5};").
Expand Down

0 comments on commit d7fdacb

Please sign in to comment.