Table of Contents
This document describes the coding style used in cinit.
Indent the code by 3 spaces for each level. Indent variable names, so the names begin all at the same position. Use three spaces to place them.
Where to put or avoid whitespaces (space or linefeed (lf)).
After start of comment and before end of comment: / text /
After ')', ','
This somehow includes the setting of braces (indirectly through (not) setting spaces.
Put the if, the braces and the opening curly brace on one line,
put the closing one together with else
and the new opening
curly brace on one line:
if(...) { /* code */ } else { /* else: code */ }
Opening and closing curly braces are placed on a seperate row:
int func(int params) { body }
where necessery, do not state the obvious in comments:
/* this code increments tmp */ ++tmp;
If there is more than one line containing a comment, try to adjust them so they look the same in width and position:
int illuminati = 23; /* do not want to comment that */ int the_answer_to_everything = 42; /* 42. */ [...] while(illuminati < the_answer_to_everything) { /* only try before them */ overtake_world(&self); /* overtake is complex */ }
Put a header into each file, containing: