【问题标题】:Space after 'if', 'while', 'catch' etc.. with clang-format'if'、'while'、'catch' 等后的空格,使用 clang 格式
【发布时间】:2019-03-22 17:44:39
【问题描述】:

无法确定该选项在ifwhilecatch 等之后添加空格...

目前我的 .clang-format 文件生成这个:

        while(true)
        {
            if(flushedCount == count)
            {
                break;
            }
        }

【问题讨论】:

    标签: c++ c clang-format


    【解决方案1】:

    ifwhilecatch等控制语句后面的clang-format配置选项控制空间称为SpaceBeforeParens

    SpaceBeforeParens: ControlStatements
    

    来自clang-format 8 documentation

    SpaceBeforeParens (SpaceBeforeParensOptions)

    定义在哪些情况下在左括号前放置一个空格。

    可能的值:

    • [...]
    • SBPO_ControlStatements(在配置中:ControlStatements)仅在控制语句关键字(for/if/while...)之后的左括号前放置一个空格。
    • [...]

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-11-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-05-11
      • 2016-08-09
      相关资源
      最近更新 更多