clang-formatフォーマットコード
clang-format is a tool to automatically format C/C++/Objective-C code, so that developers don't need to worry about style issues during code reviews.
インストール
一般的なコマンドは次のとおりです.プレビュー仕様後のコード は、元のファイル上で直接コード を規範化する.は指定コード仕様を表示し、デフォルトはLLVM 仕様をファイル に保存する
clang-format-6.0 -style=google -dump-config > .clang-format使用ファイル(ここのファイルfileは、パスを書くというわけではなく、fileを書くと自動的に.clang-formatファイルが見つかり、見つからない場合はデフォルトで使用されます) clang-format -style=file -i src/xxx.c
-iは、ソースファイルを直接変更することを意味します.
フォルダの下のファイルを一緒にフォーマットする
find ./har -iname "*.h"-o -iname "*.c"| xargs clang-format -style=file -i
インストール
$ sudo apt install clang-format
一般的なコマンドは次のとおりです.
$ clang-format main.cc
$ clang-format -i main.cc
$ clang-format -style=google main.cc
clang-format-6.0 -style=google -dump-config > .clang-format
-iは、ソースファイルを直接変更することを意味します.
フォルダの下のファイルを一緒にフォーマットする
find ./har -iname "*.h"-o -iname "*.c"| xargs clang-format -style=file -i