50 lines
713 B
Text
50 lines
713 B
Text
|
Coding style
|
||
|
============
|
||
|
Nico Schottelius <nico-cinit]at[schottelius.org>
|
||
|
0.1, for cinit, Initial version from 2006-11-13
|
||
|
:Author Initials: NS
|
||
|
|
||
|
This document describes the coding style used in cinit.
|
||
|
|
||
|
|
||
|
Indent
|
||
|
------
|
||
|
Indent the code by 3 spaces for each level.
|
||
|
|
||
|
|
||
|
Unsorted
|
||
|
---------
|
||
|
Linebreaks:
|
||
|
|
||
|
|
||
|
if(...) {
|
||
|
|
||
|
} else {
|
||
|
}
|
||
|
|
||
|
|
||
|
do {
|
||
|
} while();
|
||
|
|
||
|
no spaces
|
||
|
- within braces and code "(!test)",
|
||
|
- before braces "if(code)"
|
||
|
|
||
|
spaces
|
||
|
- after braces "if(test) return 0;"
|
||
|
- spaces before and after '=' (a = b);
|
||
|
|
||
|
curly braces:
|
||
|
functions:
|
||
|
int func(int params)
|
||
|
{
|
||
|
body
|
||
|
}
|
||
|
|
||
|
comments:
|
||
|
where necessery, do not state the obvious in comments:
|
||
|
|
||
|
/* this code increments tmp */
|
||
|
++tmp;
|
||
|
|