【问题标题】:How to correctly disable include sorting by clang-format?如何正确禁用包括按clang格式排序?
【发布时间】:2022-01-07 14:48:44
【问题描述】:

这个问答clang format: disable ordering includes,表示禁用clang-format对include排序的方法是设置如下。这可以按预期工作。

SortIncludes: false

但是,文档 (https://clang.llvm.org/docs/ClangFormatStyleOptions.html) 表明它应该是自 clang-format 4 以来的以下内容。

SortIncludes: Never

但是 clang-format (v 10.0.0-4ubuntu1) 不能理解这个

$ clang-format -i ./foo.c
YAML:40:15: error: invalid boolean
SortIncludes: Never
              ^~~~~
Error reading ./.clang-format: Invalid argument

这是文档中的错误,还是我误解了文档的内容?

【问题讨论】:

    标签: include clang-format


    【解决方案1】:

    版本仅指添加选项的时间。我遇到了同样的错误,发现自 13.0 版以来参数已经改变。不幸的是,没有关于版本之间参数更改的文档。

    从 clang 格式版本 4.0 到 12.0

    SortIncludes: {true|false}
    

    从 13.0 版开始

    SortIncludes: {Never|CaseSensitive|CaseInsensitive}
    

    【讨论】:

    • 这让阅读文档成为一种令人沮丧的体验。但是感谢您的解释!
    猜你喜欢
    • 2020-06-05
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2019-06-18
    • 1970-01-01
    • 2012-09-07
    • 2011-02-01
    • 2018-12-21
    相关资源
    最近更新 更多