 |
C++ Coding Standards
DRAFT
Basis Documents
Standards
- Formatting
- Indentation
- Tabs shall not be used, ever.
- Blocks of code
- All lines within a block of code shall be indented at least two spaces more than the containing block of code.
- The amount of indentation per block of code shall be consistent within a file.
- The braces demarking a block of code, and which are the first non-whitespace character on the line, shall be indented the same as the containing block of code.
- Continuation lines of a multi-line statement
- Continuation lines shall be indented from the beginning line of the multi-statement by at least twice as much as the amount of indentation per block of code.
- All continuation lines for a single statement shall be indented equally.
- Spacing
- Language keywords shall be separated from the open parenthesis by one space.
- There shall not be any whitespace between a function name and its open parenthesis.
- If a single space is used after a open parenthesis, a single space shall precede the corresponding close parenthesis.
- Naming
- Anything specified using
#define shall be in all upper case, underscores and numerals may be used.
- Anything not specified using
#define shall not be in all upper case.
- If any member object of a class is prefixed with
m_, all member objects of that class shall be prefixed with m_.
- Prefixes shall not be used to indicate type.
- If any object name includes a prefix indicating scope, all objects in that scope shall have the same prefix.
- Variable and function names should be terse, but descriptive.
- Names may use underscores and may be CamelCase (the first letter may be upper or lower case).
WORK IN PROGRESS
|