You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wichtounet edited this page Dec 1, 2014
·
3 revisions
Code Conventions
New code should always follow these conventions. When refactoring existing code, these conventions should be applied at least on the refactored function, ideally on the whole file.
Here are the basic code conventions of pop-cpp:
Indentation: 4 spaces (no tabs)
Braces: All the braces are declared on the same line
Braces: No structure (if, while, ...) are declared without braces
Casts: C++ style cast should be used all the time, no C-style cast should be used
Code is sufficiently spaced to be readable
C++ STL should be used when necessary
Code clarity is important
Premature optimization is the root of all evil
Example
Here is an example of a correctly formatted code:
boolfind_lib(char* libpaths[1024], int count, constchar* libname, char libfile[1024]){
for (int i = 0; i < count; i++){
sprintf(libfile, "%s/lib%s.a", libpaths[i], libname);
if (popc_access(libfile, F_OK) == 0){
returntrue;
}
}
returnfalse;
}
Current status
Currently, there are many mixed conventions used in the code.