Add clang-format to auto-format C-based languages
clang-format
is a tool that auto-formats C-based languages to a consistent and customizable style. Its various other options and integrations with various code editors can be found on the project's LLVM.org page (linked above).
The current proposed style in the .clang-format
file is as follows:
- Consecutive operators (e.g. additions) are aligned
- Consecutive ternary statements are aligned
- Lines are wrapped at 100 characters
- Overflowing lines are indented by two spaces
- Indentation is four spaces
- Pointers are aligned to the right side
- Braces are always attached to their previous statement
All of the above are subject to change if need be.
The current pull request involves changing ~15500 lines of code. This was done automatically with find . -name '*?.[ch]*' | xargs clang-format -i
from the gstlal-spiir
directory.