Changes between Version 5 and Version 6 of code/C++_styleguide
- Timestamp:
- Oct 30, 2007, 4:45:19 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
code/C++_styleguide
v5 v6 29 29 File content must be kept within 80 columns. 30 30 ''Comment: 80 columns is a common dimension for editors, terminal emulators, printers and debuggers, and files that are shared between several people should keep within these constraints. It improves readability when unintentional line breaks are avoided when passing a file between programmers.'' 31 32 === Include Guard === 33 Header files must contain an include guard. 34 {{{ 35 #ifndef MODULE_CLASSNAME_H 36 #define MODULE_CLASSNAME_H 37 38 39 #endif /* MODULE_CLASSNAME_H */ 40 }}} 31 41 32 42 == Comments == … … 77 87 ''Comment: Apart from its name and its type, the scope of a variable is its most important feature. Indicating class scope by using underscore makes it easy to distinguish class variables from local scratch variables. This is important because class variables are considered to have higher significance than method variables, and should be treated with special care by the programmer.'' 78 88 79 === Constants == 89 === Constants === 80 90 Named constants (including enumeration values) must be all uppercase using underscore to separate words. Always use constants instead of numbers. 81 91 {{{ … … 134 144 }}} 135 145 146 136 147 == Indentation == 137 148 === Spaces === 138 149 Use 2 spaces for an indentation level. Never use tabs, as it is common in windows IDEs. 139 150 151 === Split Lines === 152 The incompleteness of split lines must be made obvious: 153 {{{ 154 totalSum = a + b + c + 155 d + e; 156 function(param1, param2, 157 param3); 158 159 setText("Long line split" 160 "into two parts."); 161 162 for (int tableNo = 0; tableNo < nTables; 163 tableNo += tableStep) { ... } 164 }}} 140 165 141 166 == Whitespaces == … … 143 168 144 169 145 146 147 170 === Include Statements === 171 Include statements should be sorted and grouped. Sorted by their hierarchical position in the system with low level files included first. Leave an empty line between groups of include statements. 172 {{{ 173 #include <fstream> 174 #include <iomanip> 175 176 #include <qt/qbutton.h> 177 #include <qt/qtextfield.h> 178 179 #include "com/company/ui/PropertiesDialog.h" 180 #include "com/company/ui/MainWindow.h" 181 }}} 148 182 149 183