Skip to content

Commit f3be806

Browse files
docs: fix brace and control-statement parenthesis spacing; update .clang-format and documentation
1 parent a128472 commit f3be806

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ ColumnLimit: 100 # Maximum line width
3333
# -----------------------------------------------------------------------------
3434
# Spaces
3535
# -----------------------------------------------------------------------------
36-
SpaceBeforeParens: Never # No space before function call parentheses
36+
SpaceBeforeParens: ControlStatements # Space before parentheses for control statements (if/for/while); function calls remain tight
3737
SpacesInContainerLiterals: true # Enforce spaces in container literals
3838
SpaceBeforeAssignmentOperators: true # Add space before assignment operators
3939
SpacesInParentheses: false # No extra spaces inside parentheses

clang-format.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ auto result = some_object.with_a_very_long_name()
7171

7272
# 3. 空格规则(Spaces)
7373

74+
7475
对应配置:
7576

7677
```yaml
77-
SpaceBeforeParens: Never
78+
SpaceBeforeParens: ControlStatements
7879
SpacesInContainerLiterals: true
7980
SpaceBeforeAssignmentOperators: true
8081
PointerAlignment: Left
@@ -83,7 +84,7 @@ QualifierAlignment: Left
8384
8485
规则说明:
8586
86-
- 函数名与括号之间 **不允许空格**
87+
- 函数调用与括号贴紧(`foo(1)`);控制语句(`if/for/while`)与括号之间保留空格(`if (cond)`)。
8788
- 容器字面量 **强制空格**
8889
- 赋值运算符两侧必须有空格
8990
- 指针/引用贴近类型

0 commit comments

Comments
 (0)