= Code Formatting

== C/C++

The sources have a uniform coding formatting based on the
https://google.github.io/styleguide/cppguide.html#Formatting[Google Style].

The style is defined in the _.clang-format_ file which when used
by https://clang.llvm.org/docs/ClangFormat.html[clang-format] produces a
correctly formatted source file. 

Since the 5.10 release all source file modifications must be processed by
clang-format to be accepted. The recommended way to do this is using a git
pre-commit hook which applies formatting when committing changes

To do this, just install the pre-commit program from https://pre-commit.com/:
    
    $ pip install pre-commit

and then, in the project top directory

    $ pre-commit install

which will pick up the configuration from _.pre-commit-config.yaml_ which is 
part of the project.

== CMake

Cmake file uses formatting defined by the _.cmake-format.yaml_ which when used
with https://github.com/cheshirekow/cmake_format[cmake-format] produces
correctly formatted files. This has been applied to all _cmake/*.cmake_ files
and CMakeLists.txt.

== Using clang-format

clang is part of the llvm tools. These are usually installed using package
managers like choco (Windows), brew (MacOS) or apt (Debian/Ubuntu).

To format a C, C++ or header file with clang-format with the project's default 
configuration use:

    clang-format -i  <filename>

== Using  cmake-format

Install cmake-format as described in
https://github.com/cheshirekow/cmake_format[]. To format a single file use

    cmake-format -i  <filename>

== Editor and IDE configuration

There is a  _.editorconfig_ file in the top directory.
This file could be used by most editors to define basic settings.

There are no standard configurations available for IDEs like Visual Studio
Code, Eclipse or CLion.
