Clang格式不使用.clang格式的文件ubuntu(没有错误)

Clang-format not using .clang-format file ubuntu (no errors)

本文关键字:格式 ubuntu 有错误 文件 clang Clang      更新时间:2023-10-16

我的项目目录中有一个.clang-format,里面有我的.cpp文件和构建目录。从我的终端,我cd到我的项目文件夹并运行clang-format -style=file -i *.cpp.这是我.clang-format文件。

Language: Cpp
ColumnLimit: 0
BreakBeforeBraces: GNU
BreakConstructorInitializers: AfterColon
Cpp11BracedListStyle: true
IndentCaseLabels: true
NamespaceIndentation: All
IndentWidth: 4
TabWidth: 4
UseTab: Never
DerivePointerAlignment: false
PointerAlignment: Left
IncludeBlocks: Regroup

我正在通过更改BreakBeforeBraces来测试功能,但没有任何变化。它似乎正在使用回退格式。这是怎么回事?有没有办法看到clang-format实际上在做什么?

当使用-style=file时,每个输入文件的 clang 格式将尝试查找位于输入文件最近的父目录中的 .clang 格式文件。使用标准输入时,将从当前目录开始搜索。

您可以使用以下命令查看运行目录中使用的实际配置

clang-format -style=file -dump-config