For the aspects not explained in this document, follow the coding style described in: http://llvm.org/docs/CodingStandards.html == #include Style == * Avoid #includes in the header files. Use forward declarations if possible. * Immediately after the header file comment (and include guards if working on a header file), the minimal list of #includes required by the file should be listed. We prefer these #includes to be listed in this order: 1) Main Module Header 2) Local/Private Headers 3) 4) System #includes * do not use 'using ...;' in header files == Mechanical Source Issues == * use standard header-guard: #ifndef PACPUS_EXAMPLE_H #define PACPUS_EXAMPLE_H ... #endif // PACPUS_EXAMPLE_H * use C++-style comments (//) * ALWAYS use curly brackets with statements if, for, etc. * use curly brackets {} as follows: * on the same line with: - namespace { - statements if, for, etc. if (cond) { } else if (cond2) { } else { } * on the next line with: - classes - function and method definitions - local scope blocks class A { void fun A; struct AB { }; void fun A { } }; * write Doxygen-style comments as much as possible, put it in the header file if possible, add developer-only comments in source file * use Java-style Doxygen comments, i.e. @returns over \returns * use preprocessor directives for long-range comments (#if 0 .... #endif) * indent with 4 spaces, do not use tabs * do not indent namespaces * use camelCaseNotation / CamelCaseNotation * end namespace with its name in a comment * start with a lowercase letter for local variables, namespaces, function names, method names, ... * start with an Uppercase for classes, structs, ... * prefix member variables with 'm' * prefix (static) const variables with 'k' * prefix static (non-const) variables with 's' * separate member methods from member variables with a repetion of 'protected:' / 'private:' ======================================== Example.h: ======================================== /// File description #ifndef PACPUS_EXAMPLE_H #define PACPUS_EXAMPLE_H #include "BaseClass.h" namespace pacpus { /// Constant description static const double kConstA; /// Static variable description static int sStaticA; /// Brief description of this class /// /// Somewhat longer description of this class class SomeClass : public BaseClass { public: SomeClass private: void methodA(); private: int mMemberA; }; } // namespace pacpus #endif // PACPUS_EXAMPLE_H ======================================== Example.cpp: ======================================== #include "Example.h" #include "Something.h" #include "SomethingElse.h" #include #include using namespace pacpus; const double kConstA = 3.14159265; SomeClass::SomeClass() : BaseClass() { int someIntegerVariable; if (a) { a(); } else { b(); } if (isConditionSatisfied()) { doSomething(); return 0; } return 1; }