Automatic Code FormattingΒΆ
Note
A pull request will only be accepted if the C++ code is formatted correctly!
To have one unified C++ code formatting style, we use clang-format.
Clang-format automatically formats source code according to a set of pre-defined rules.
Our current style can be found in the .clang-format file file in the root folder of the repository:
1---
2BasedOnStyle: LLVM
3AccessModifierOffset: -4
4AllowShortBlocksOnASingleLine: Empty
5AllowShortCaseLabelsOnASingleLine: false
6AllowShortFunctionsOnASingleLine: Empty
7AllowShortIfStatementsOnASingleLine: Never
8AllowShortLoopsOnASingleLine: false
9AlwaysBreakTemplateDeclarations: Yes
10ColumnLimit: 120
11IndentWidth: 4
We recommend to install plugins which auto format the code when the file is being saved.
Instructions for how to enable clang-format in Microsoft Visual Studio can be found here.
Other editors like Visual Studio Code, Notepad++ and Sublime Text support this as well.
Part of our continuous integration (CI) is an automated clang-format check using GitHub actions.
Our setup of clang-format with GitHub actions can be here.