Next: A. The GNU General
Up: Ion: Notes for the
Previous: 4 Miscellaneous design notes
Contents
Index
Subsections
If you want to submit patches to Ion, you MUST follow my coding
style, even if you think it is the root of all evil. We don't want
the code to be an incomprehensible mess of styles and I have better
things to do than fix other people's style to match mine. The style
should be obvious by studying the source, but here's a list of some
things to take note of.
- Opening brace is at the end of the line, except in function
bodies, where it is at the beginning of the line following
the definition.
- Never put the body of a control statement on the same line
with the statement (e.g.
if(foo){ bar() }
).
For example, the block
void foo(int a, int b)
{
if(a==b && c+d==e){
...
}
}
has correct style while the block
void foo(int a,int b) {
if (a == b && c + d == e) {
...
}
}
does not.
- The else keyword follows immediately after the closing brace of
previous if, if any. (This might change so I don't care if you put
it on the next line.)
- I have used the convention that control statement bodies containing
a single statement do not need braces around the block if, in case of
the if all the blocks in if ... else if ... else
contain just one statement. If you want to, just use braces in every
case.
- Function and variable names only have lower case letters. Type
names are in mixed case while constants and macros (#defines)
are in upper case letters.
I think that's mostly it. Study the source when in doubt.
Next: A. The GNU General
Up: Ion: Notes for the
Previous: 4 Miscellaneous design notes
Contents
Index