-
Notifications
You must be signed in to change notification settings - Fork 773
Coding Style
Josh Klontz edited this page Jul 21, 2014
·
14 revisions
The most important rule is that new code should be consistent with the existing code around it. The rules below illustrate the preferred style when cleaning up existing inconsistently-styled code.
These rules are a work in progress and are subject to additions. Changes to the style can be made with a pull request implementing the change across the entire repository.
struct FooBar
{
};
int *fooBar(const int &x, int *y, int z)
{
*y = x + z;
return y;
}
int x = 2;
int *y = &x;
int &z = x;
for (int i=start; i<end; i++)
foo();
for (int i=start; i<end; i++) {
foo();
bar();
}
Use const
whenever possible.
Use static
function declarations whenever possible but static
variables sparingly.
int foo(int used, int)
{
// Unused variables are nameless in the function definition
return used;
}
4 spaces, no tabs.