Skip to content

C++ naming conventions and style guides used within Plume.

License

Notifications You must be signed in to change notification settings

mwalczyk/plume_cpp_style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

Plume C++ Style Guide

plume logo

Naming Conventions

Class and struct names should be CamelCase.

Variable and function names should be all lowercase and separated by underscores (ex. int number_of_wheels).

In addition, the following prefixes should be used:

  • m_ for member variables
  • s_ for static variables
  • g_ for global variables

Note that function parameters have no special prefix.

Use ALL_CAPS for macro and enum fields only - not constants.

Example:

enum class ErrorCode
{
  ERROR_OUT_OF_MEMORY,
  ERROR_BAD_PATH,
  // ...
}

Namespaces should also be all lowercase and separated by underscores (ex. namespace graphics).

Modifiers

Reference and pointer modifiers (& and *) always appear closest to the type.

Examples:

// Free-standing variables
T* ptr;

// Function return types
T& operator[](size_t index);

// Function parameters
void set_value(T& value);

Curly Braces

Always place curly braces on newlines. This includes:

  • Class / struct declarations
  • If-else blocks
  • Try-catch statements
  • Switch statements
  • Function definitions
  • Etc.

Example:

if (condition)
{
  // ...
}

Comments

Use doxygen style //! comments above class and function declarations to describe their intended purpose / functionality.

Otherwise, use the standard // comment notation. Do not use /* */ for multi-line comments.

Class Structure

Use the public before protected before private order.

Within each block, items should appear in the following order:

  1. using declarations and typedefs
  2. Static functions
  3. Constructors
  4. Destructors
  5. Member functions
  6. Static variables
  7. Member variables
  8. friend declarations

About

C++ naming conventions and style guides used within Plume.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published