blob: 45318ab3143d9be7fd7d9d14262cdaf267146be3 (
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
32
33
34
|
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.
About: Unit tests
- Unit test files have the `.test.c` extension.
|