5 | | * Names' words shall be separated by underscore "_". |
6 | | * Types shall be suffixed with "_t". |
7 | | * Macros shall be upper case. |
| 5 | === Source file encoding === |
| 6 | |
| 7 | * Source files are encoded in UTF-8 |
| 8 | * Only ASCII subset should be used, except for cases of internationalized string literals |
| 9 | * New lines are represented by the LF ('\n') character. Do not use CR + LF or CR. |
| 10 | |
| 11 | === Identifiers === |
| 12 | |
| 13 | * C identifiers should be written in lower case, words separated by underscore "_" (foo_bar) |
| 14 | * Types shall be suffixed with "_t" |
| 15 | * Preprocesor symbols shall be all-upper case (FOO_MACRO(), FOO_CONSTANT) |
12 | | * Only use English names. |
13 | | * Variables with a large scope should have long names, variables with a small scope can have short names. |
14 | | * Use name prefixes for identifiers declared in different modules. |
| 20 | * Only use English names (English words, intelligible abbreviations) |
| 21 | * Symbols with narrow scope (local variables) may have terse names (e.g. i) |
| 22 | * Symbols with wide scope must have reasonably unique and meaningful names |
| 23 | * Symbols with module scope or wider scope should follow the prefixing convention (e.g. fibril_create) |
18 | | * Do not use spaces for indentation, except for long line wrapping purposes. |
19 | | * Consider breaking long lines at 80-character boundary. The wrapped line should continue indented four spaces to the right of the original indentation. |
| 27 | * Use a single Tab character for indentation, except for line continuations. |
| 28 | * Tab width is considered to be 8 characters. |
| 29 | * A line continuation is indented exactly 4 spaces. |
| 30 | * Lines should not, in general, exceed 80 characters (tab counting as 8). |
27 | | * All binary arithmetic, bitwise and assignment operators and the ternary conditional operator (?:) shall be surrounded by spaces; the comma operator shall be followed by a space but not preceded; all other operators shall not be used with spaces. |
| 39 | * Labels in functions and switch statements are not indented (i.e. indented one less tab than the other contents of the block) |
| 40 | |
| 41 | === Spacing === |
| 42 | |
| 43 | * All binary arithmetic, bitwise and assignment operators and the ternary conditional operator (?:) shall be surrounded by spaces |
| 44 | * The comma operator shall be followed by a space but not preceded |
| 45 | * All other operators shall not be used with spaces. |
| 46 | * For functions and function-like operators there should be no extra spaces around or inside parentheses (int foo(void), sizeof(bar_t)) |
| 47 | * For control statements with parenteses there should be one space between the keyword and opening parenthesis (if (a == b)) |
| 48 | * Return statements should omit parentheses, especially when the argument is simple (return 1;) |
| 49 | * Function-like operators (sizeof()) must never omit parentheses |
| 50 | * There should be no space after asterisk (in type declarations or when dereferencing) (int *foo(int *f), *f = *g[3]) |
| 51 | |
| 52 | === Blank lines === |
| 53 | |
| 54 | * There should be newline at the end of every source file |
| 55 | * There should be one blank line between any two top-level declarations that include a { } body - functions, enums, structs |