* same with xv6
[mascara-docs.git] / i386 / MIT / course / src / git.lab / CODING
blob898097ee5d92d419aaf08e0d06995ae5bdd42f7e
1 JOS CODING STANDARDS
3 It's easier on everyone if all authors working on a shared
4 code base are consistent in the way they write their programs.
5 We have the following conventions in our code:
7 * No space after the name of a function in a call
8   For example, printf("hello") not printf ("hello").
10 * One space after keywords "if", "for", "while", "switch".
11   For example, if (x) not if(x).
13 * Space before braces.
14   For example, if (x) { not if (x){.
16 * Function names are all lower-case separated by underscores.
18 * Beginning-of-line indentation via tabs, not spaces.
20 * Preprocessor macros are always UPPERCASE.
21   There are a few grandfathered exceptions: assert, panic,
22   static_assert, offsetof.
24 * Pointer types have spaces: (uint16_t *) not (uint16_t*).
26 * Multi-word names are lower_case_with_underscores.
28 * Comments in imported code are usually C /* ... */ comments.
29   Comments in new code are C++ style //.
31 * In a function definition, the function name starts a new line.
32   Then you can grep -n '^foo' */*.c to find the definition of foo.
34 * Functions that take no arguments are declared f(void) not f().
36 The included .dir-locals.el file will automatically set up the basic
37 indentation style in Emacs.