adding brief code-style section to Developer_tips

This commit is contained in:
Chris Hall 2016-07-28 19:07:14 +10:00
parent a83b9df0e3
commit 70884a882e

View File

@ -19,3 +19,49 @@ C functions defined within `shared/` must also be bound by a file within `lisp/`
more information on this will be provided in this document later.
Code formatting
---------------
C code is automatically formatted using `clang-format`,
if you have `clang-format` installed you can invoke the formatter via running:
# from the top level directory
$ cmake .
$ make format
It is recommend that you format your code before making a pull request,
although semi-regular formats are run to catch any code that wasn't
pre-formatted.
A quick outline of the C style:
- 2 space indent
- Never use tabs
- No column width limit
A very short example showing some of the features of this style
int main(int argc, char **argv) {
int a = 14;
int *b = &a;
switch(a) {
case 14:
puts("a was 14")
break;
default:
puts("I have no idea what happened")
break;
}
if(*b > 5) {
puts("*b is bigger than 5")
}
else {
puts("*b is not bigger than 5")
}
}