This project uses clang-format to keep the code style consistent. The .clang-format file in the project root is based on the Google C++ style guide with a few project-specific tweaks.
Make sure clang-format is available before you use it:
Windows:
powershell winget install LLVM # or with Chocolatey choco install llvm
Linux:
bash sudo apt install clang-format # Ubuntu/Debian sudo dnf install clang-tools-extra # Fedora
macOS:
bash brew install clang-format
Format a single file:
bash clang-format -i path/to/your/file.cpp
Format the entire project:
bash # Run from the project root find main -iname '*.h' -o -iname '*.cc' | xargs clang-format -i
Check formatting without modifying files (useful in CI / pre-commit):
bash clang-format --dry-run -Werror path/to/your/file.cpp
C_Cpp.formatting to clangFormat in settings.editor.formatOnSave.Editor > Code Style > C/C++ in the settings.Formatter to clang-format.{ on the same line as the control statement).cpp // clang-format off your code // clang-format on clang-format is too old..clang-format file..clang-format in the project root is actually picked up..clang-format higher in the tree is winning.Questions and suggestions are welcome - please open an issue or a pull request.