1 SuperTux Coding Standards
2 =========================
4 * start member variable name with "m_", global variables with "g_" and
5 static variables with "s_"
7 * avoid spaces at the end of lines
9 * proper separation between generic engine code and game specific code
10 should be done whenever feasible
12 * the path in #include directives must not contain "..", all paths
13 must be relative to the src/ directory
15 * external libraries are not allowed in src/, they go to external/
17 * do not use raw pointer and new/delete, use std::unique_ptr<> instead
19 * properly separate data members and member functions, don't mix them
20 in the same public/private/protected section
22 * conditional includes should be indented:
25 # include "foobar.hpp"
28 * use #include <> for libraries in external/
30 * include guards are of the form:
32 #ifndef HEADER_SUPERTUX_{PATH}_{FILE}_HPP
33 #define HEADER_SUPERTUX_{PATH}_{FILE}_HPP
35 * use one file per class
37 * write namespaces like: "namespace NameSpace {", no newline before the '{', finish them with:
38 "} // namespace Namespace"
40 * compile with the maximum warning level and with -Werror:
42 -Werror -ansi -pedantic -Wall -Wextra -Wnon-virtual-dtor -Weffc++
43 -Wcast-qual -Winit-self -Wno-unused-parameter
45 possible additional flags for the future: -Wconversion -Wshadow
47 * write doxygen comments as:
49 /** This is a comment */
51 do not use /**< and other styles of comments
53 * write regular comments with //, not with /* */
55 * more info on good practices can be found at:
57 http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml