3
ClangFormat usage tips
source link: https://rigtorp.se/notes/clang-format/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
ClangFormat usage tips
2020-09-19In this note I provide useful tips on how to use ClangFormat (somtimes called clang-format).
Run clang-format to check if a file is already formatted:
clang-format --dry-run -Werror foo.c || echo "not formatted!"
Run clang-format in parallel to check if files are formatted:
find . -iname "*.c" -or -iname "*.h" | xargs -P0 -I{} clang-format --dry-run -Werror {}
Run clang-format in parallel to reformat files:
find . -iname "*.c" -or -iname "*.h" | xargs -P0 -I{} clang-format -i {}
Useful command line options:
-Werror
: causes clang-format to return non-zero exit status if any input file is not already formatted.--dry-run
: don’t actually format, only check if files are formatted
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK