- Currently, code should target C++17 standard, i.e., should not use C++2x features yet. The C++ version targeted by this guide will advance (aggressively) over time
- Do not use non-standard extensions
- Consider portability to other environments before using features from C++14 and C++17 in your project
- In general, every .cpp file should have an associated .hpp file
- Correct use of header files can make a huge difference to the readability, size and performance of your code
- We use #pragma include guards
#pragma once
- Include headers in the following order: Related header, C system headers, C++ standard library headers, other libraries' headers, your project's headers
- All of a project's header files should be listed as descendants of the project's source directory without use of UNIX directory aliases . (the current directory) or .. (the parent directory)
- Like every other module of Inexor the entity system uses namespaces:
namespace inexor {
namespace entity_system {
// Code here..
};
};
- Namespaces wrap the entire source file after includes and forward declarations of classes from other namespaces.
The following standard libraries will be used in the code:
- We use clang format for source code formatting (format style options)
- A .clang-format file is placed in the project tree. The is some support for automatically use the code formatter:
Entity Kind | Naming Convention |
---|---|
Namespace | snake_case |
Class | PascalCase |
Enum | SCREAMING_SNAKE_CASE |
Enumerator | PascalCase |
Typedef | PascalCase |
Union | PascalCase |
Member Function | snake_case |
Member Field | snake_case |
Global Function | snake_case |
Global Variable | snake_case |
Method Parameter | snake_case |
Local Variable | snake_case |
Macro | SCREAMING_SNAKE_CASE |
Directory Names | kebab-case |
Test Files | Postfix _tests |
Benchmark Files | Postfix _benchmark |
TODO