c++ - 'if'、'while'、'catch' 等后的空格,使用 clang 格式
问题描述
无法弄清楚该选项会在if
, while
,catch
等之后添加空格...
目前我的 .clang-format 文件产生这个:
while(true)
{
if(flushedCount == count)
{
break;
}
}
解决方案
The clang-format
configuration option controlling space after if
, while
, catch
and other control statements is called SpaceBeforeParens
.
SpaceBeforeParens: ControlStatements
From clang-format 8 documentation:
SpaceBeforeParens (
SpaceBeforeParensOptions
)Defines in which cases to put a space before opening parentheses.
Possible values:
- [...]
SBPO_ControlStatements
(in configuration:ControlStatements
) Put a space before opening parentheses only after control statement keywords (for/if/while...
).- [...]
推荐阅读
- wpf - 如何在 UWP 中为举行活动设置自定义持续时间?
- swift - @FetchRequest 模拟使用标准观察记录计数
- python - 通过python连接oracle DB
- dataset - KITTI 数据集中训练数据的标签文件
- javascript - 如何使用按钮将值粘贴到页面中?
- ssh - SSH远程端口转发空响应
- azure-data-explorer - Kusto 子查询引用“外部”查询
- bash - UNIX 文件元数据:可移植的可解析解决方案(例如 POSIX / ubiquitous)
- c# - 通过 Lambda 或按属性名称访问 ComObject
- naming-conventions - 是否有命名约定来区分包含普通 Gherkin、空手道 UI 和空手道 API 的 .feature 文件?