-
Notifications
You must be signed in to change notification settings - Fork 58
/
CodingStyle.txt
55 lines (38 loc) · 1.24 KB
/
CodingStyle.txt
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
50
51
52
53
54
$Id$
vim: spelllang=en tw=78
This is a short introduction to the coding style that shall be used. The below
rules are applicable for all C source files, except the Ethernet drivers, for
which the Linux Kernel coding style shall be used to minimize the
differences).
1) Line length
- Lines shall not exceed 78 characters.
2) Whitespace
- Indentation shall be done using 4 space characters
- No whitespace shall be left at the end of a line.
- After commas, colons and semicolons, a single space shall be
placed (if not followed by a line break).
- Binary operators (=, ==, ~=, |, ||, etc.) shall be enclosed by 2 spaces
(except . and ->).
3) Placing braces
- Braces shall be placed in the following way (K&R style):
if (...) {
...
} else if (...) {
...
} else {
...
}
int function(...)
{
...
}
4) Defines and Macros
- Defines and macros shall be named in CAPITAL letters. If a macro contains
multiple statements, they should be enclosed by a 'do {} while (0)' loop.
Macro parameters shall also be capital letters and shall be enclosed py
parantheses if necessary.
#define MACRO(A, B) \
do { \
if ((A) == 1) { \
statement(B); \
} while (0)