-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.clang-format
More file actions
38 lines (35 loc) · 2.19 KB
/
.clang-format
File metadata and controls
38 lines (35 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
BasedOnStyle: Google # 继承 Google 风格
AllowShortFunctionsOnASingleLine: Empty # 允许短函数一行显示(Empty 允许空函数)
BreakConstructorInitializers: AfterColon # 构造函数初始化列表换行
ColumnLimit: 120 # 单行最大字符数 120
ConstructorInitializerAllOnOneLineOrOnePerLine: true # 构造函数初始化列表一行或一行一个
ConstructorInitializerIndentWidth: 2 # 构造函数初始化列表缩进
ContinuationIndentWidth: 2 # 换行缩进宽度 2
DerivePointerAlignment: false # 禁用自动指针对齐
IndentCaseLabels: false # 控制 case: label 本身是否缩进
IndentWidth: 2 # 缩进宽度 2
PointerAlignment: Right # 确保 type &var 风格
ReflowComments: true # 自动调整 /** ... */ 的换行格式
TabWidth: 2 # Tab 宽度 2
UseTab: Never # 使用空格缩进
# AlignConsecutiveAssignments: true # 启用连续赋值对齐
BreakBeforeBraces: Custom # 使用自定义大括号规则
BraceWrapping:
AfterClass: true # ✅ 类的大括号换行
AfterControlStatement: true # ✅ if/for/while 换行
AfterEnum: true # ✅ 枚举的大括号换行
AfterFunction: true # ✅ 函数的大括号换行
AfterNamespace: true # ✅ 命名空间的大括号换行
AfterStruct: true # ✅ struct 的大括号换行
BeforeCatch: true # ✅ catch 大括号也换行
BeforeElse: true # ✅ else 换行
IndentBraces: false # ❌ 大括号不额外缩进
##############################################################
# 如果你对某段代码的格式非常满意,不希望 clang-format 修改它
# 请使用 clang-format off/on 忽略代码块
#
# // clang-format off
# 满意的代码片段,不需要 clang-format 修改它
# // clang-format on
#
##############################################################