== General C++ quality guidelines == C++ is a tricky language to master, and it is extremely easy to write slow and/or inefficient code in it. Though nothing replaces experience and trial and error, having some background is recommended. A well written and quite comprehensive, if somewhat old, guide can be found here: [http://www.agner.org/optimize/optimizing_cpp.pdf].\\ Furthermore, users that are not used to C++ should check out the ([http://isocpp.org/wiki/faq/ C++ FAQ]), which answers a decent amount of interrogations that Stack Overflow would otherwise answer confusingly. Users that knew classic C++ will also find a comprehensive review of C++11. Please make sure to use only the modern C++ features that are supported by 0 A.D. If you have a doubt, consult the page CppSupport. Also the page CodeAndMemoryPerformance is here to remind you of some habits to write more efficient code. == Code quality checking tools == This page is a random assortment of ideas and tools for improving quality (detecting potential bugs etc). It doesn't include things that are run automatically (like most compiler warnings). Most things are not supported on all OSes. === Valgrind === Run the tests or the game or Atlas in Valgrind, to get reports of uninitialised memory and leaks and so on. The code should run cleanly with no errors (though there may be errors reported in drivers which you need to ignore). Valgrind is really really slow, so we probably ought to have some way to record real-time inputs and play them back at Valgrind speeds, but we don't really have that now. === GCC warnings === * `-Wstrict-overflow=5` - some discussion [http://www.airs.com/blog/archives/120 here]. Only gives useful output in optimised builds (`CONFIG=Release make`). Warns about cases where the compiler optimises based on assumptions that signed overflow never happens; our code should be certain those assumptions will not be violated. (There are lots of false positives so the warning isn't on by default). === Cppcheck === * Free C/C++ static analysis tool; looks for memory leaks, uninitialized variables, etc. Windows binary is available, http://cppcheck.sourceforge.net/ === Clang Static Analyzer === Compile using `scan-build make` and then inspect the output using `scan-view`.