Skip to content
This repository has been archived by the owner on Sep 18, 2020. It is now read-only.

Cpp coding convention

Grzegorz Mrukwa edited this page Jul 27, 2017 · 5 revisions

Naming Convention

Descriptive names. If necessary, prefer long names over shortcuts.

  • Class names: PascalCase
  • Methods/Function names: PascalCase
  • Local variables: camelCase
  • Class fields: m_Name
  • Static names: s_Name
  • Global variables: g_Name
  • Namespaces: PascalCase
  • Constants: UPPERCASE_WITH_UNDERSCORES
  • Macros: SAME_AS_ABOVE
  • Enum names: PascalCase
  • Constants in enums: UPPERCASE_WITH_UNDERSCORES

Braces:

if (true)
{
// not java-like
}

Also, prefixing pointers with p, i. e. m_pWindow, or pObject.

Basic type names

We use short alias of each basic type, i.e. we use unsigned instead of unsigned int.

auto

Please avoid using auto as it can potentially make the code barely readable.

Convention Reference

When in doubt, please refer to http://www.insomniacgames.com/core-coding-standard/

New project guidelines

When creating new project in C++, one should remember to add appropriate property sheet just after creation of the project. These file is dependent on the type of project created:

  1. For native C++ code project, the file is: NativeProject.props
  2. For native C++ test project, the file is: NativeTestProject.props
  3. For managed C++/CLI code project, the file is: ManagedCppProject.props
  4. For managed C++/CLI test project, the file is: ManagedCppTestProject.props

All property sheet files are located in .../src/PropertySheets.