Spacing
- indentation: one tab stop
- one space before opening parenthesis
- no space after opening parenthesis
- one space after a comma: foo (x, y) not foo (x,y)
- one space around operators (x == y, x && y, x != y, x = y, ...)
- no space around . and ->
Bracing
- opening brace on the same line as if, else, for, switch, case & while
- else on the same line as if closing brace
- braces in case statements allowed (if new scope needed) but not required
- open and close braces for functions on own separate lines.
- opening and closing braces required even for single line if, for,
while statements
Naming
- use low case except in SAF libraries which should follow the SAF coding style guidelines.
- use descriptive names
- words separated with underscore
- functions preferably named object_verb
Misc
- Max 3 levels of indentation recommended
- Max line length 80 chars or less
- Functions should be short and do one thing
- Pointer comparisons with NULL not 0
- Comments, see example
- C++ comments not allowed
- No multiple statements on a single line
- gotos OK for centralized exit of functions
- When in doubt, check Steven's code and K&R C book