2
2
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
3
3
---
4
4
Language : Cpp
5
- # 访问说明符 (public、 protected、 private)不偏移
5
+ # Do not offset access specifiers (public, protected, private)
6
6
AccessModifierOffset : -4
7
- # 开括号(开圆括号、开尖括号、开方括号)后的参数换行需要对齐
7
+ # Align parameters after opening brackets (round, angle, square)
8
8
AlignAfterOpenBracket : Align
9
- # 连续赋值时,不对齐所有等号
9
+ # Do not align consecutive assignments
10
10
AlignConsecutiveAssignments : false
11
- # 连续声明时,不对齐所有声明的变量名
11
+ # Do not align consecutive declarations
12
12
AlignConsecutiveDeclarations : false
13
- # 对齐连续宏定义的样式
13
+ # Align consecutive macros
14
14
AlignConsecutiveMacros : true
15
- # 将转义的换行符(\)尽可能向左对齐
15
+ # Align escaped newlines to the left
16
16
AlignEscapedNewlines : Left
17
- # 水平对齐二元和三元表达式的操作数
17
+ # Align operands of binary and ternary expressions horizontally
18
18
AlignOperands : true
19
- # 对齐连续的尾部注释
19
+ # Align trailing comments
20
20
AlignTrailingComments : true
21
- # 允许函数的所有参数放到下一行
21
+ # Allow all function arguments on the next line
22
22
AllowAllArgumentsOnNextLine : false
23
23
AllowAllConstructorInitializersOnNextLine : false
24
24
AllowAllParametersOfDeclarationOnNextLine : false
25
- # 不允许短的代码块放在同一行,如 while 代码块
25
+ # Do not allow short blocks (e.g., while blocks) on a single line
26
26
AllowShortBlocksOnASingleLine : false
27
- # 不允许短的 case 标签代码块放在同一行
27
+ # Do not allow short case labels on a single line
28
28
AllowShortCaseLabelsOnASingleLine : false
29
- # 不允许在类外定义的非空函数放在同一行
29
+ # Do not allow non-empty functions defined outside of a class on a single line
30
30
AllowShortFunctionsOnASingleLine : Inline
31
- # 不允许短的 if 语句放在同一行
31
+ # Do not allow short if statements on a single line
32
32
AllowShortIfStatementsOnASingleLine : false
33
- # 不允许短的循环代码块放在同一行
33
+ # Do not allow short loop blocks on a single line
34
34
AllowShortLoopsOnASingleLine : false
35
- # 不要主动在函数定义返回类型处换行,除非超过行字符数限制必须换行
35
+ # Do not break after the return type in function definitions, unless it exceeds the column limit
36
36
AlwaysBreakAfterDefinitionReturnType : None
37
37
AlwaysBreakAfterReturnType : None
38
- # 不允许在多行 string 前换行
38
+ # Do not break before multiline strings
39
39
AlwaysBreakBeforeMultilineStrings : false
40
- # 总是在 template 声明后换行
40
+ # Always break after template declarations
41
41
AlwaysBreakTemplateDeclarations : Yes
42
- # 不要求函数实参换行时必须每个参数各自一行
42
+ # Do not require each function argument to be on a separate line
43
43
BinPackArguments : false
44
- # 不要求函数形参换行时必须每个参数各自一行
44
+ # Do not require each function parameter to be on a separate line
45
45
BinPackParameters : false
46
- # 配置大括号是否换行
46
+ # Configure brace wrapping style
47
47
BraceWrapping :
48
- # case 标签后面大括号不换行
48
+ # Do not break after case labels
49
49
AfterCaseLabel : false
50
- # class 定义后面大括号不换行
50
+ # Do not break after class definitions
51
51
AfterClass : false
52
- # 控制语句后面大括号不换行
52
+ # Do not break after control statements
53
53
AfterControlStatement : false
54
- # enum 定义后面大括号不换行
54
+ # Do not break after enum definitions
55
55
AfterEnum : false
56
- # 函数定义后面大括号不换行
56
+ # Do not break after function definitions
57
57
AfterFunction : false
58
- # 命名空间定义后面大括号不换行
58
+ # Do not break after namespace definitions
59
59
AfterNamespace : false
60
- # struct 定义后面大括号不换行
60
+ # Do not break after struct definitions
61
61
AfterStruct : false
62
- # union 定义后面大括号不换行
62
+ # Do not break after union definitions
63
63
AfterUnion : false
64
- # extern 块后面大括号不换行
64
+ # Do not break after extern blocks
65
65
AfterExternBlock : false
66
- # catch 之前需要换行
66
+ # Break before catch statements
67
67
BeforeCatch : true
68
- # else 之前需要换行
68
+ # Break before else statements
69
69
BeforeElse : true
70
- # lambda 大括号不换行
70
+ # Do not break before lambda bodies
71
71
BeforeLambdaBody : false
72
- # while 之前需要换行
72
+ # Break before while statements
73
73
BeforeWhile : true
74
- # 不要缩进大括号
74
+ # Do not indent braces
75
75
IndentBraces : false
76
- # 空函数体可以在同一行
76
+ # Allow empty function bodies on a single line
77
77
SplitEmptyFunction : false
78
- # 空语句可以在同一行
78
+ # Allow empty statements on a single line
79
79
SplitEmptyRecord : false
80
- # 空命名空间可以在同一行
80
+ # Allow empty namespaces on a single line
81
81
SplitEmptyNamespace : false
82
- # 需要换行时在二元操作符前换行,除了赋值操作符
82
+ # Break before binary operators, except for assignment operators
83
83
BreakBeforeBinaryOperators : NonAssignment
84
- # 在 BraceWrapping 中自定义
84
+ # Customize break before braces in BraceWrapping
85
85
BreakBeforeBraces : Custom
86
- # 继承列表换行时逗号不换行
86
+ # Do not break after commas in inheritance lists
87
87
BreakBeforeInheritanceComma : false
88
- # 继承列表换行时冒号换行,逗号不换行
88
+ # Break before colons in inheritance lists, but not before commas
89
89
BreakInheritanceList : BeforeColon
90
- # 在三元运算操作符之前换行
90
+ # Break before ternary operators
91
91
BreakBeforeTernaryOperators : true
92
- # 构造函数初始化列表换行时逗号不换行
92
+ # Do not break after commas in constructor initializer lists
93
93
BreakConstructorInitializersBeforeComma : false
94
- # 构造函数初始化列表换行时冒号换行,逗号不换行
94
+ # Break before colons in constructor initializer lists, but not before commas
95
95
BreakConstructorInitializers : BeforeColon
96
- # 允许断开字符串文字
96
+ # Allow breaking string literals
97
97
BreakStringLiterals : true
98
- # 每行字符数限制
98
+ # Column limit for each line
99
99
ColumnLimit : 120
100
100
CommentPragmas : ' ^ IWYU pragma:'
101
- # 不允许不同的命名空间定义在同一行
101
+ # Do not allow different namespaces to be defined on the same line
102
102
CompactNamespaces : false
103
- # 构造函数初始化列表要么都在一行,要么每个变量一行
103
+ # Constructor initializer lists should either be all on one line or one per line
104
104
ConstructorInitializerAllOnOneLineOrOnePerLine : true
105
- # 构造函数初始化列表需要 4 个缩进
105
+ # Indent constructor initializer lists by 4 spaces
106
106
ConstructorInitializerIndentWidth : 4
107
- # 换行后下一行需要 4 个 缩进
107
+ # Indent continuation lines by 4 spaces
108
108
ContinuationIndentWidth : 4
109
- # 变量初始化列表前后不需要空格
109
+ # No spaces around variable initialization lists
110
110
Cpp11BracedListStyle : true
111
111
DerivePointerAlignment : true
112
112
DisableFormat : false
113
113
ExperimentalAutoDetectBinPacking : false
114
- # 自动为命名空间结尾处添加注释
114
+ # Automatically add comments at the end of namespaces
115
115
FixNamespaceComments : true
116
116
ForEachMacros :
117
117
- foreach
@@ -130,23 +130,23 @@ IncludeCategories:
130
130
- Regex : .*
131
131
Priority : 3
132
132
IncludeIsMainRegex : ([-_](test|unittest))?$
133
- # switch 里的 case 需要缩进
133
+ # Indent case labels inside switch statements
134
134
IndentCaseLabels : true
135
- # extern 里的代码块需要缩进
135
+ # Indent code blocks inside extern blocks
136
136
IndentExternBlock : Indent
137
- # 预处理指令不能有缩进
137
+ # Do not indent preprocessor directives
138
138
IndentPPDirectives : None
139
- # 使用 4 个缩进
139
+ # Use 4 spaces for indentation
140
140
IndentWidth : 4
141
- # 函数声明、定义时在返回类型处换行时,下一行不要缩进
141
+ # Do not indent wrapped function names after the return type
142
142
IndentWrappedFunctionNames : false
143
- # 代码块开始处不要有空行
143
+ # Do not keep empty lines at the start of code blocks
144
144
KeepEmptyLinesAtTheStartOfBlocks : false
145
145
MacroBlockBegin : ' '
146
146
MacroBlockEnd : ' '
147
- # 不能有连续2个及以上的空行
147
+ # Do not allow consecutive empty lines
148
148
MaxEmptyLinesToKeep : 1
149
- # 命名空间内的内容不要缩进
149
+ # Do not indent contents inside namespaces
150
150
NamespaceIndentation : None
151
151
PenaltyBreakAssignment : 2
152
152
PenaltyBreakBeforeFirstCallParameter : 1
@@ -156,7 +156,7 @@ PenaltyBreakString: 1000
156
156
PenaltyBreakTemplateDeclaration : 10
157
157
PenaltyExcessCharacter : 1000000
158
158
PenaltyReturnTypeOnItsOwnLine : 200
159
- # * & 紧挨类型名
159
+ # * and & should be placed next to the type name
160
160
PointerAlignment : Left
161
161
RawStringFormats :
162
162
- Language : Cpp
@@ -186,39 +186,39 @@ RawStringFormats:
186
186
- ParseTextProtoOrDie
187
187
CanonicalDelimiter : ' '
188
188
BasedOnStyle : google
189
- # 允许对注释重新排版
189
+ # Allow reflowing of comments
190
190
ReflowComments : true
191
- # 允许对 #include 排序
191
+ # Allow sorting of #include statements
192
192
SortIncludes : true
193
- # 允许对 using 声明排序
193
+ # Allow sorting of using declarations
194
194
SortUsingDeclarations : true
195
- # c 风格类型转换括号后不要有空格
195
+ # Do not include spaces after C-style casts
196
196
SpaceAfterCStyleCast : false
197
- # template 关键字后面需要一个空格
197
+ # Require a space after the template keyword
198
198
SpaceAfterTemplateKeyword : true
199
- # 赋值运算符两边需要空格
199
+ # Require spaces around assignment operators
200
200
SpaceBeforeAssignmentOperators : true
201
- # 变量初始化列表大括号前不要有空格
201
+ # Do not include spaces before C++11 braced initializer lists
202
202
SpaceBeforeCpp11BracedList : false
203
- # 构造函数初始化冒号前需要空格
203
+ # Require a space before the colon in constructor initializers
204
204
SpaceBeforeCtorInitializerColon : true
205
- # 继承语句冒号前需要一个空格
205
+ # Require a space before the colon in inheritance statements
206
206
SpaceBeforeInheritanceColon : true
207
- # 控制语句后面需要一个空格 (if/ for/ while.. .)
207
+ # Require a space after control statement keywords (if, for, while, etc .)
208
208
SpaceBeforeParens : ControlStatements
209
- # 基于范围循环的冒号前需要一个空格
209
+ # Require a space before the colon in range-based for loops
210
210
SpaceBeforeRangeBasedForLoopColon : true
211
- # 不要在空的圆括号内添加空格
211
+ # Do not include spaces inside empty parentheses
212
212
SpaceInEmptyParentheses : false
213
- # 同行尾随注释 // 前面需要一个空格
213
+ # Require a space before // in trailing comments
214
214
SpacesBeforeTrailingComments : 1
215
- # 尖括号前后没有空格
215
+ # Do not include spaces around angle brackets
216
216
SpacesInAngles : false
217
- # c 风格类型转换的括号中前后没有空格
217
+ # Do not include spaces around C-style cast parentheses
218
218
SpacesInCStyleCastParentheses : false
219
- # 圆括号前后没有空格
219
+ # Do not include spaces around parentheses
220
220
SpacesInParentheses : false
221
- # 方括号前后没有空格
221
+ # Do not include spaces around square brackets
222
222
SpacesInSquareBrackets : false
223
223
Standard : Auto
224
224
StatementMacros :
0 commit comments