-
Notifications
You must be signed in to change notification settings - Fork 39
/
STYLE
35 lines (31 loc) · 1.11 KB
/
STYLE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
Indent style:
- indent 4 spaces
- use same-line brace placement without cuddled else, i.e.
if(something) {
code();
}
else {
more_code();
}
- if statements without braces must be on one line:
if(x) LOG(1, "error");
- if code is longer than ~80 characters, wrap and indent 4 chars, e.g.
if(this && that && something_else() && ...
&& ...) {
// ... code
}
void long_function_name(arg1, arg2, ...,
argN, argN+1) {
// ... code
}
- for functions in header files, write on one line or wrap at braces:
virtual Chunk *getParent() const { return parent; }
virtual SpatialChunkList<ChildType> *getSpatial()
{ if(!spatial) createSpatial(); return spatial; }
Other points:
- consider forward declaring classes to reduce header dependencies
- all output should go through LOG macros
- if log/log.h is included in any .cpp file, it should be the last #include
- all getter functions should be const if possible
- use address_t for addresses (not void*, unsigned long, etc)
- wrap arch-specific code in ARCH_* macros, or #error if not supported