gpt4 book ai didi

c++ - Clang 格式不使用 .clang 格式文件 ubuntu(无错误)

转载 作者:塔克拉玛干 更新时间:2023-11-03 07:38:00 27 4
gpt4 key购买 nike

我的项目目录中有一个 .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-format 将尝试找到位于输入的最近父目录 中的 .clang-format 文件文件。使用标准输入时,从当前目录开始搜索。

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

clang-format -style=file -dump-config

关于c++ - Clang 格式不使用 .clang 格式文件 ubuntu(无错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57959505/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com