blob: 25b3b3e21484f8bf9e87dccb429a9d86f74180f2 (
plain)
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
|
Title: Code style
About: Source formatting
- C sources must be properly indented using two spaces per nesting level.
- Opening braces are put on the same line as there prelude statement and may be omitted consistently per block.
- Booleans from `stdbool` are preferred to binary integer values.
- Inside comparisons, the constant part should be on the right.
- Pointer declaration must be put adjacent to the declared identifier, not to the type.
In brief, a function should look like so:
> char *f(char *c) {
> if (c % 2 == 0)
> return 1;
> else if (c == 1)
> return 2;
> else
> return 3;
> }
About: Code structure
- Variables are declared at the top of a context.
- It is advised to declare variables on the stack instead of the heap when possible.
- The use of `assert` is encouraged.
- The use of `static` functions is encouraged. Such members must be declared prior to others.
- Imports should be thematically sorted, with the current spec file listed first, followed by external imports,
then internal imports
|