Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 1.7 KB

README.md

File metadata and controls

46 lines (31 loc) · 1.7 KB

Coding conventions

Coding conventions are described in coding_conventions.tex file. Generate output with pdlatex:

pdflatex coding_conventions.tex

All developers are obliged to follow them.

Source code formatter.

The source code will be reformatted using the clang-format. The format rules are inside .clang-format file in this repository. Copy or symlink the file to the root directory of your project.

1. Manually invoking formatter

You can reformat file at any time using clang-format. The program check for .clang-format file in the directory of teh file or any parent directory. That is why we can put it just in the project root directory. Then invoke format with

clang-format --style=file -i path/to/source/file.cc

Without -i option program will return to stdout the formatted code, with -i it will update file in place.

If you wish to reformat all the files in the directory, run

find . \( -iname "*.hh" -or -iname "*.cc" -or -iname "*.C" \) -exec clang-format --style=file -i {} \;

2. When using KDevelop IDE

  1. Copy format_source to root directory of your project.

  2. Open Project Options and choose Source Formatter. Select C++ language and choose Custom Script Formatter and in the list select kdev_format_source.

  3. The source formatting can be invoked by Edit->Reformat Source. It is suggested to assign a shortcut to the action, e.g. F2. Before each commit source should be reformatted.

  4. Parts of the code which should be excluded from formatting must be enclosed with // clang-format off and // clang-format on comments:

    void formatted_code;
    // clang-format off
        void    unformatted_code  ;
    // clang-format on