Skip to content

Latest commit

 

History

History
136 lines (100 loc) · 1.57 KB

File metadata and controls

136 lines (100 loc) · 1.57 KB

Styling Guidelines

If Statements

Single Statement Blocks

if (expression) {
    // Code
}

Compound Statements

if (expression)
{
    // Code
}

Switch Statements

switch (expression)
{
    case 1:
        // Code, try to keep it small (call a function, or call max 3 instructions)
        break;
    case 2:
        // Code, try to keep it small (call a function, or call max 3 instructions)
        break;
    default:
        break;
}

Classes

class ClassName
{
    public:
        // Code
    protected:
        // Code
    private:
        // Code
};

Member Variables

class ClassName
{
    private:
        void mFunctionName();

        int mVariableName;

        // Code
};

Functions

Declarations

void FunctionName(parameters);

Definitions

void FunctionName(parameters)
{
    // Code
}

Temporary Variables

int variableName;

Global Variables

int gVariableName;

Constant Variables

Do not do:

#define CONSTANT_VARIABLE_NAME value

Instead do:

constexpr int CONSTANT_VARIABLE_NAME = value;

Templates

template<typename Type_T>
void FunctionName(Type_T name);

Function Parameters

void FunctionName(int parameterName);

Includes

Including goes in this order:

  • Your own headers
  • C++ headers
  • Other libraries' headers

Example:

#include "TIMGE/TIMGE.hpp" // Your own libraries first

#include <iostream> // C++ libraries second

#include <glfw/glfw3.h> // Other libraries third