Skip to content
ptroja edited this page Dec 1, 2010 · 16 revisions

Coding style

For newly created content to be added into project:

  • authors of the files have to be listed in the top header comment in the Doxygen tag format
  • C++ code formatting have to follow Eclipse CDT .xml code style file located in the top folder
  • #define should not be used for constants or computational macros; they are allowed for metaprogramming-like jobs
  • functions and variables floating in the global namespace should not be used
  • functions and variables should be scoped inside a class, which make use of them
  • printf/cout debug data about correct program execution

For existing content

Considered as critical bugs

  • dynamic memory allocation is allowed only at system initialization; after that it breaks a real-time characteristics

Considered as bad style

  • use of C-style arrays of numeric data; [[Eigen::Matrix|http://eigen.tuxfamily.org/dox/TutorialCore.html#TutorialCoreMatrixTypes]] is recommended
  • iterating collections with for loops; [[BOOST_FOREACH|http://www.boost.org/doc/libs/release/doc/html/foreach.html]] is recommended
  • use of POSIX threads; [[Boost:Thread|http://www.boost.org/doc/libs/release/doc/html/thread.html]] is recommended
  • use of pointers where reference can be used
  • use of reference without const qualifiers

Ideas stolen from

Tools to check C++ code style