Version 1 (modified by 16 years ago) (diff) | ,
---|
Coding Standards
We try to follow K&R coding style in most of or code. Here are some examples to help explain:
Braces
- Braces start at the same line as the if/while/do/for block
- End braces are on their own lines, indented to the starting of the
block, e.g.:
for (i = 0; i < x; i++) { /* the code here, indented by a tab */ }
- The starting braces for functions, structs etc. are on their own lines e.g.:
struct _somestruct { /* stuff */ };
Indentation
- We use tab for indentation (and it's preferable that you use 8-space tabs in your editor)
Whitespace
- A space (or a newline) after ; , =
- A space in front of = and ( except for function calls. e.g.:
for (i = 0; i < x; i++) .. some_function(var1, var2);
Comments
- A comment or two in the static (non-exported) functions is good, but not essential.
- Every function added in any header file must be documented. See any of the header files in our tree for example.