Skip to content
This repository has been archived by the owner on Feb 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request twitter#127 from kevyang/56
Browse files Browse the repository at this point in the history
Update bool member rules in style guide
  • Loading branch information
kevyang committed May 16, 2016
2 parents 780941a + a4fb927 commit 648d19e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/c-styleguide.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@
<stdint.h>. However, when interfacing with system calls and libraries
you cannot get away from using int and char.
- Use bool for boolean variables. You have to include <stdbool.h>
- Avoid using a bool as type for struct member names. Instead use unsigned
1-bit bit field. Eg:
- If memory usage or alignment is a concern, avoid using a bool as type for
struct member names. Instead use unsigned 1-bit bit field. e.g.
struct foo {
unsigned is_bar:1;
};
However, if neither memory usage or alignment will be significantly impacted
by the struct, opt for using bool for the sake of readability.
- Always use size_t type when dealing with sizes of objects or memory ranges.
- Your code should be 64-bit and 32-bit friendly. Bear in mind problems
of printing, comparisons, and structure alignment. You have to include
Expand Down

0 comments on commit 648d19e

Please sign in to comment.