Changeset 16169 in vbox
- Timestamp:
- Jan 22, 2009 2:17:56 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/doc/VBox-CodingGuidelines.cpp (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/VBox-CodingGuidelines.cpp
r9396 r16169 44 44 * 45 45 * - Use static wherever possible. This makes the namespace less polluted 46 * and avoid nasty name clash problems which can occur e, especially on46 * and avoid nasty name clash problems which can occur, especially on 47 47 * Unix like systems. (1) 48 48 * … … 61 61 * them from defines. 62 62 * 63 * - Pointer typedefs start with 'P'. If pointer to const valuethen 'PC'.64 * 65 * - Function typedefs start with 'FN'. If pointer to onethen 'PFN'.63 * - Pointer typedefs start with 'P'. If pointer to const then 'PC'. 64 * 65 * - Function typedefs start with 'FN'. If pointer to FN then 'PFN'. 66 66 * 67 67 * - All files are case sensitive. … … 71 71 * - char strings are UTF-8. 72 72 * 73 * - All functions return s VBox status codes. There are three general exceptions74 * from this:75 * -# Predicate functions. These are function which are boolean in nature76 * and usage. They return bool. The function name will include77 * 'Has', 'Is' or similar.73 * - All functions return VBox status codes. There are three general 74 * exceptions from this: 75 * -# Predicate functions. These are function which are boolean in 76 * nature and usage. They return bool. The function name will 77 * include 'Has', 'Is' or similar. 78 78 * -# Functions which by nature cannot possibly fail. 79 79 * These return void. … … 91 91 * - Other useful constructs are also put in the IPRT. 92 92 * 93 * - The code shall not cause compiler warnings. Check this withon ALL93 * - The code shall not cause compiler warnings. Check this on ALL 94 94 * the platforms. 95 95 * … … 99 99 * 100 100 * - All public functions are fully documented in Doxygen style using the 101 * javadoc dialect (using the 'at' insdead of the 'slash' as commandprefix.) 102 * 103 * - All structures in header files are described, including all of their 101 * javadoc dialect (using the 'at' instead of the 'slash' as 102 * commandprefix.) 103 * 104 * - All structures in header files are described, including all their 104 105 * members. 105 106 * … … 107 108 * describes the intent and actual implementation. 108 109 * 109 * - Code which is doing things that are not immediat ly comprehendable110 * shall include explanatory comments !110 * - Code which is doing things that are not immediately comprehensible 111 * shall include explanatory comments. 111 112 * 112 113 * - Documentation and comments are kept up to date. 113 114 * 114 * - Headers in /include/VBox shall not contain any slash-slash C++ comments,115 * only ansiC comments!115 * - Headers in /include/VBox shall not contain any slash-slash C++ 116 * comments, only ANSI C comments! 116 117 * 117 118 * … … 123 124 * shared libraries. The Windows / PE __declspect(import) and 124 125 * __declspect(export) constructs are the main reason for this. 125 * OT H, we do perhaps have a bit too detailed graining of this in VMM...126 * OTOH, we do perhaps have a bit too detailed graining of this in VMM... 126 127 * 127 128 * … … 153 154 * 154 155 * - RT_OS_WINDOWS is defined to indicate Windows. Do not use __WIN32__, 155 * __WIN64__ and __WIN__ because they are all deprecated and schedule 156 * __WIN64__ and __WIN__ because they are all deprecated and scheduled 156 157 * for removal (if not removed already). Do not use the compiler 157 158 * defined _WIN32, _WIN64, or similar either. The bitness can be … … 181 182 * for this purpose. 182 183 * 183 * - RT_ARCH_AMD64 is defined when compiling for the AMD64 thearchitecture.184 * - RT_ARCH_AMD64 is defined when compiling for the AMD64 architecture. 184 185 * Do not use __AMD64__, __amd64__ or __x64_86__. 185 186 * … … 200 201 * @section sec_vbox_guideline_optional Optional 201 202 * 202 * First part is the actual coding style and all the prefixes the second part is203 * thea bunch of good advice.203 * First part is the actual coding style and all the prefixes. The second part 204 * is a bunch of good advice. 204 205 * 205 206 * … … 217 218 * @endcode 218 219 * 219 * - The else of an if is always first statement on a line. (No curly220 * - The else of an if is always the first statement on a line. (No curly 220 221 * stuff before it!) 221 222 * 222 * - else and if goes on the same line if no curly stuff is needed around the if. 223 * - else and if go on the same line if no { compound statement } 224 * follows the if. 223 225 * Example: 224 226 * @code … … 254 256 * 255 257 * - In a do while construction, the while is on the same line as the 256 * closing bracketif any are used.258 * closing "}" if any are used. 257 259 * Example: 258 260 * @code … … 267 269 * disabling a few lines of code. 268 270 * 269 * - Slig tly complex boolean expressions are splitt into multiple lines,271 * - Slightly complex boolean expressions are split into multiple lines, 270 272 * putting the operators first on the line and indenting it all according 271 273 * to the nesting of the expression. The purpose is to make it as easy as … … 338 340 * - When writing code think as the compiler. 339 341 * 340 * - When reading code think as that it's fullyof bugs - find them and fix them.342 * - When reading code think as if it's full of bugs - find them and fix them. 341 343 * 342 344 * - Pointer within range tests like: … … 350 352 * Which is shorter and potentially faster. (1) 351 353 * 352 * - Avoid unnecessary casting. All pointers automatically cast s down to void *,353 * at least for non class instance pointers.354 * - Avoid unnecessary casting. All pointers automatically cast down to 355 * void *, at least for non class instance pointers. 354 356 * 355 357 * - It's very very bad practise to write a function larger than a 356 * screen full (1024x768) without any comprehendable and explaining comments. 358 * screen full (1024x768) without any comprehensibility and explaining 359 * comments. 357 360 * 358 361 * - More to come.... … … 393 396 } 394 397 @endcode 395 * If I understood it correctly, the compiler will convert a to an unsigned long before396 * doing the compare.398 * If I understood it correctly, the compiler will convert a to an 399 * unsigned long before doing the compare. 397 400 * 398 401 * … … 407 410 * NEVER CHECK IN TO A BROKEN BUILD. 408 411 * 409 * - When checking in keep in mind that a commit is atomic aland that the Tinderbox and412 * - When checking in keep in mind that a commit is atomic and that the Tinderbox and 410 413 * developers are constantly checking out the tree. Therefore do not split up the 411 * commit unless it's into 100% indepen tant parts. If you need to split it up in order414 * commit unless it's into 100% independent parts. If you need to split it up in order 412 415 * to have sensible commit comments, make the sub-commits as rapid as possible. 413 416 * 414 * - Make sure you add an entry to the ChangeLog file. 417 * - If you make a user visible change, such as fixing a reported bug, 418 * make sure you add an entry to doc/manual/user_ChangeLogImpl.xml. 415 419 * 416 420 *
Note:
See TracChangeset
for help on using the changeset viewer.

