clang-format

Endless_daydream Lv4

安装

1
sudo apt install clang-format

使用

‵‵`sh
clang-format –style=LLVM main.cpp

1
2
3
4
5
6
7
8
9

默认输出到标准输出,使用`--style`指定格式,在‵man clang-format`中查看支持的选项,通常有LLVM, GNU, Google, Microsoft, Mozilla等。

要直接替换源文件内容,使用选项`-i`

### 自定义配置文件

```sh
clang-format --dump-config --style=LLVM > .clang-format

生成配置文件内容打印到标准输出,将输出保存到.clang-format或_clang-format,这样当指定了-style=file选项时,将从文件所在目录及其上级目录寻找配置文件来格式化。

配置选项含义可见 1 2

  • Title: clang-format
  • Author: Endless_daydream
  • Created at : 2024-05-02 20:14:14
  • Updated at : 2024-05-04 09:09:15
  • Link: https://endless_daydream.gitee.io/2024/05/02/cpp/clang-format/
  • License: This work is licensed under CC BY-NC-SA 4.0.
Comments
On this page
clang-format