-
Notifications
You must be signed in to change notification settings - Fork 273
Coding rules and cpplint #293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4bb5660
38865d1
e9a20ce
a7c24fb
e36bdd0
e24acd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,31 @@ | ||
Here a few minimalistic coding rules for the cprover source tree: | ||
|
||
a) 2 spaces indent, no tabs | ||
b) no "using namespace std;" | ||
c) Avoid new/delete, use containers instead. | ||
d) Avoid unnecessary #includes, especially in header files | ||
e) No lines wider than 80 chars | ||
f) Put matching { } into the same column | ||
g) If a method is bigger than a page, break it into parts | ||
h) Avoid destructive updates if possible. The irept has | ||
constant time copy. | ||
- Use 2 spaces indent, no tabs. | ||
- No lines wider than 80 chars. | ||
- If a method is bigger than a page, break it into parts. | ||
- Put matching { } into the same column. | ||
- Do not use namespaces. | ||
- Prefer use of 'typedef' insted of 'using'. | ||
- Prefer use of 'class' instead of 'struct'. | ||
- User defined type identifiers have to be terminated by 't'. Moreover, | ||
before 't' may not be '_'. | ||
- Avoid new/delete, use containers instead. In other words, do not perform | ||
heap operations directly. | ||
- Write type modifiers before the type specifier. | ||
- Do not use 'm_' prefix nor '_' suffix for names of attributes of structured | ||
types. | ||
- Avoid destructive updates if possible. The irept has | ||
constant time copy. | ||
- Avoid unnecessary #includes, especially in header files | ||
- We allow to use 3rd libraries directly. No wrapper matching the coding rules | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should that be 3rd-party libraries (instead of "3rd libraries")? |
||
is required. Allowed libraries are: C++ standard library. | ||
- No "using namespace std;". | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redundant with "Do not use namespaces" |
||
- Use instances of std::size_t for comparison with return values of .size() of | ||
SLT containers and algorithms, and use them as indices to arrays or vectors. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. s/SLT/STL/ |
||
- Prohibited stuff from the standard library: ??? TODO! | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What would be prohibited? |
||
|
||
Architecture-specific code: | ||
|
||
a) Avoid if possible. | ||
b) Use __LINUX__, __MACH__, and _WIN32 to distinguish the architectures. | ||
c) Don't include architecture-specific header files without #ifdef ... | ||
- Avoid if possible. | ||
- Use __LINUX__, __MACH__, and _WIN32 to distinguish the architectures. | ||
- Don't include architecture-specific header files without #ifdef ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code base, by and large, actually uses 70 chars. Though be sensible about it: don't trade extra-short (and then meaningless) variable names for achieving short lines.