| 1 |
|
| 2 |
|
| 3 |
Based on the Webkit style |
| 4 |
|
| 5 |
C++ codes files end in ".cc", header files end in ".hh" - lowercase file names prefered. |
| 6 |
|
| 7 |
Spaces not tabs (never tabs) |
| 8 |
|
| 9 |
Line length limit: 128 characters |
| 10 |
|
| 11 |
3 character indent |
| 12 |
|
| 13 |
Spaces and else usage: usually like this: |
| 14 |
|
| 15 |
int a = 1; |
| 16 |
if (a < 10) { |
| 17 |
// something |
| 18 |
} else { |
| 19 |
// something else |
| 20 |
} |
| 21 |
|
| 22 |
except in the for loop, where the spaces around the operator are removed: |
| 23 |
|
| 24 |
for (int i=0; i<10; i++) { |
| 25 |
} |
| 26 |
|
| 27 |
std::cout: |
| 28 |
|
| 29 |
std::cout << "first thing" |
| 30 |
<< "aligned on the <<" |
| 31 |
<< std::endl; |
| 32 |
|
| 33 |
Never pass by reference (non-const reference) unless the function which you are calling |
| 34 |
is less than 30 lines of code away (in which case it is allowed, but not prefered), i.e. |
| 35 |
variables that are modified by a function are marked by passing a pointer (variable_p) |
| 36 |
or &variable (preferably the later). |
| 37 |
|