Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page documents how source code autoformatting tools can be used to enforce the Zubax C++ coding conventions.

There is no such thing as a decent autoformatter for C++, so the existing ones should be used with care. It is advised to enforce the coding conventions manually (e.g. during code review), and use autoformatters only if the code needs to be converted from a different codebase where a different set of formatting rules was used.




Unlike AStyle or Uncrustify, clang-format doesn't tend to break your code or introduce nonsensical changes. The configuration file below requires clang-format version 8 or newer. Note that clang-format can't enforce brace placement and some other things; consider using clang-tidy for that.

View file

The file can be used as followsPut the config file in the sources' root directory, then run from the same directory:

Code Block
titleInvoking Uncrustify
clang-format --replacei --no-backupfallback-style=none -c uncrustify.cfg style=file src/*.[ch]pp

Eclipse IDE autoformatter