Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Version 5 and Version 6 of code/C++_styleguide


Ignore:
Timestamp:
Oct 30, 2007, 4:45:19 PM (17 years ago)
Author:
patrick
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/C++_styleguide

    v5 v6  
    2929File content must be kept within 80 columns.
    3030''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 ===
     33Header 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}}}
    3141
    3242== Comments ==
     
    7787''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.''
    7888
    79 === Constants ==
     89=== Constants ===
    8090Named constants (including enumeration values) must be all uppercase using underscore to separate words. Always use constants instead of numbers.
    8191{{{
     
    134144}}}
    135145
     146
    136147== Indentation ==
    137148=== Spaces ===
    138149Use 2 spaces for an indentation level. Never use tabs, as it is common in windows IDEs.
    139150
     151=== Split Lines ===
     152The incompleteness of split lines must be made obvious:
     153{{{
     154totalSum = a + b + c +
     155           d + e;
     156function(param1, param2,
     157         param3);
     158
     159setText("Long line split"
     160        "into two parts.");
     161
     162for (int tableNo = 0; tableNo < nTables;
     163     tableNo += tableStep) { ... }
     164}}}
    140165
    141166== Whitespaces ==
     
    143168
    144169
    145 
    146 
    147 
     170=== Include Statements ===
     171Include 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}}}
    148182
    149183