forked from mikaku/Fiwix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCODING
50 lines (31 loc) · 1.72 KB
/
CODING
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
Fiwix kernel coding standards
-------------------------------------------------------------------------------
It's easier on everyone if all authors working on a shared code base are
consistent in the way they write their programs. Fiwix has the following
conventions in its code:
- Use of snake_case (multi-word names are lower_case_with_underscores) for
everything except for macro and constant names.
- No space after the name of a function in a call.
For example, printk("hello") not printk ("hello").
- Optional space after keywords "if", "for", "while", "switch".
For example, if(x) or if (x).
- Space before braces (except in function declarations).
For example, if(x) { not if(x){.
- Space between operands.
For example, for(n = 0; n < 10; n++), not for(n=0;n<10;n++).
- Beginning-of-line indentation via tabs, not spaces.
- Preprocessor macros are always UPPERCASE.
- Pointer types have spaces: (uint16_t *) not (uint16_t*).
- Comments in code are always as in C89 /* ... */.
- Multiline comments start always with a capital letter and the last sentence
ends with a period.
- Functions that take no arguments are declared as f(void) not f().
- The open parenthesis is always on the same line as the function name.
- There is never a space between the function name and the open parenthesis.
- There is never a space between the parentheses and the parameters.
- The open curly brace is always at the next line of the function declaration.
- Conditionals should always include curly braces, even if there is only a
single statement within the conditional.
Recommended for reading
-------------------------------------------------------------------------------
- http://skull.piratehaven.org/~bapper/298c/cstyle.html