Other Coding Rules

From OpenMW Wiki
Revision as of 13:56, 11 August 2011 by Rhys (talk | contribs) (Created page with "== Namespaces == We prefer fully qualified names (e.g. std::cout). Using directives (e.g. using namesapce std) are not welcome. Using directives in headers will result in the c...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Namespaces

We prefer fully qualified names (e.g. std::cout).

Using directives (e.g. using namesapce std) are not welcome. Using directives in headers will result in the code being rejected.

Using declarations (e.g. using std::cout) are tolerated, but should be used only in the innermost possible scope (i.e. usually function scope). Fully qualified names are still preferred.

Other Pieces of Advice

  1. Prefer C++ means over C means.
  2. Prefer STL-container over raw arrays and new[]/delete[].
  3. Use new/delete only when necessary. Prefer automatic storage duration.
  4. Throw exceptions instead of retuning error codes.
  5. When returning a pointer, don't return a 0-pointer in case of an error (returning a 0-pointer is still valid, if it does not represent an error situation)
  6. Don't use C++0x features (until we made sure everyone's compiler supports these)
  7. Remember the Rule of Three.