C++ 代码格式化
.
格式化
be/src
和be/test
目录下的 C/C++ 代码。check-format.sh
.检查
be/src
和 目录下的 C/C++ 代码格式,并将 diff 输出,但不会修改文件内容。
Doris的代码风格在Google Style的基础上稍有改动,定制为 .clang-format
文件,位于Doris根目录。
目前,.clang-format
配置文件适配clang-format-8.0.1以上的版本。
需要下载安装clang-format,也可使用IDE或Editor提供的clang-format插件,下面分别介绍。
Ubuntu: apt-get install clang-format
当前版本为10.0,也可指定旧版本,例如:
Mac: brew install clang-format
Centos 7:
centos yum安装的clang-format版本过老,支持的StyleOption太少,建议源码编译10.0版本。
cd到Doris根目录下,然后执行如下命令:
build-support/clang-format.sh
Clion
Clion如果使用插件,点击即可。
VS Code
VS Code需安装扩展程序Clang-Format,但需要自行提供clang-format执行程序的位置。
打开VS Code配置页面,直接搜索”clang_format”,填上