Compialation
- remove all warnings clang -Weverything gcc -Wall -Wextra -Wpedantic valgrind --show-leak-kinds=all --leak-check=full
- under all cicumstances have (atleast a wrapper) Makefile for frenliness
- GNU Make ok, that other Make with a prefix shall burn in hell
- NOTE: (to Xolatile in particular) fuck splint
Multi-line comments
- single line for separating logical blocks inside the same block
- multiline for exaplaining code /* stuff * and more */
- use them very sparsely
Headers
- never use relative paths, manipulate the compiler
- use #define type header guards
- header guards shall be all caps _
- make function forward declarations explicitly
extern
Macros
- only with consensus can any new macro be added to the codebase
- always parenthesize values
Identaion
- tabs
- max 4 levels
Parenthesizing
- do not parenthesize return statements
- always add spacing around when after a control statement {
if (condition) {...}
} - do not pad the insides {
(stuff) ; and not: ( stuff )
} - do not pad after function context {
myfun();
} - always use to avoid relying on operator precedence {
(a * b) + c
}
Declarations
- pointer '*'s always to the middle {
char * s;
} - dont concat pointer '*'s {
char \* \* s;
} - function heads belong on the same line
- [static|extern] [inline] [type]
- align adjecent ones horizontally
- always typedef structs or make them anonymous
If
- align logical operators under the keyword if if (a && b && c) {}
- align negating operators and the lack of there of if (!a && b && !c) {}
- always omit useless comperasions if (a) // good if (a != 0) // bad
Switch
switch(...) {
case ...: {
} beak;
}
- GNU range extensions allowed
Loops
- declare the iterator inside the loop
- variables to use for iteration 'i' -> 'j' -> 'k'
- use "while(1)" for infinit loops
- no coma in condition unless its an assignment
- never ommit brackets at empyt loop bodies
Operators
- prefer prefix crementors when possible {
++i;
} - use spaces (if you dont intuetively know what this means, kys)
Naming
- namer chooses spelling, consistency must follow
- snake_case
- *_t on all typedefs
- LOCAL variables shall be short enough to not use snake_case
Misc
- keep a line width of 80
Description
Languages
Shell
48.9%
TeX
19%
C++
13.6%
Perl
10.7%
C
7.4%
Other
0.4%