Coding style
NOTE: this is yet unfinished
The following are guidelines for the code formatting to use in Code::Blocks (C::B) source code. Anyone writing code or a patch for C::B, is required to follow these.
The general coding style is the ANSI one:
Example:
namespace FooSpace { int Foo() { if (isBar) { Bar(); return 1; } else return 0; } }
Variables naming
Class names do not have to start with 'C' (as in CObject, CWindow, etc). Only abstract base classes (interfaces) should start with 'I'. But they all have to start with a capital letter.
Class member variables should start with m_. If the variable is a pointer, use m_p as a prefix. Following the prefix is the variable's name. Use descriptive names and use capital letters at the start of each word (the first too). So a fictious variable holding a value for position would be named as m_ValueForPosition.
Non-class member variables should not start with a capital letter.
Function names should always start with a capital letter.
Examples:
// Good int aLocalVar; int m_SomeInt; void* m_pSomePointer; bool SomeFunc(); // Bad int SomeInt; // either no m_ prefix if it's a class variable, or capital first letter if it's a local variable int m_someInt; // no capital letter 'S' void* m_SomePointer; // no m_p prefix bool someFunc(); // function with non-capital first letter
Variables declaration
One variable declared each time on a different line. For pointer/reference variables, put the * or & right after the type not before the variable name.
Examples:
// Good int& someInt; void* pPtr; // Bad int &someInt; // & not after type void* pPtr, pSomeOther; // multiple declarations in one line
Spacing
Prefer spaces over tabs. If you want to use tabs you won't be prosecuted (!) but please use a tab size of 4 characters.
Code indentation should be 4 characters.
In class declarations, the keywords public:, protected: and private: should be indented. The same goes for all the class members.
Examples:
// Good class AClass { public: AClass(){ ... } protected: int m_Member; }; // Bad class AClass { public: AClass(){ ... } protected: int m_Member; };