Revision 1 as of 2010-11-15 18:15:28

Clear message

Back to developer page.

C++ coding conventions and style guide

This is not meant to be a complete description of our coding conventions. When in doubt, follow the example of the existing code.

To keep the size of this page reasonable, the following parts have been broken out to a separage page:

General recommendations

We generally follow the recommendations in the book C++ Coding Standards: 101 Rules, Guidelines, and Best Practices by Herb Sutter and Andrei Alexandrescu. In the tracker or elsewhere, a mark of the form [SA x] is a reference to a rule in that book. For example, [SA 9] refers to Sutter and Alexandrescu's rule 9: "Don’t pessimize prematurely".

Namespaces

Header file guards

Macro names for header file guards follow this algorithm:

Example: learning/state_space_sample.h becomes LEARNING_STATE_SPACE_SAMPLE_H.

Guard blocks should look like this:

   1 #ifndef LEARNING_STATE_SPACE_SAMPLE_H
   2 #define LEARNING_STATE_SPACE_SAMPLE_H
   3 // ...
   4 #endif
   5 

That's all. In particular, don't add comments to the preprocessor directives and don't add further underscores.

Function signatures

Anti-idioms