@chengzhao-dev/dsh-cpp-workflow 0.7.3 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +7 -7
- package/README.md +7 -7
- package/lib/client.js +1 -1
- package/lib/comment-policy.js +1 -1
- package/package.json +9 -3
- package/skills/building-cpp/SKILL.md +14 -14
- package/skills/building-cpp/examples/environment.md +4 -3
- package/skills/building-cpp/references/{build-script.md → 01-build-script.md} +4 -3
- package/skills/building-cpp/references/{environment.md → 02-environment.md} +3 -2
- package/skills/building-cpp/steps/01-build.md +2 -2
- package/skills/building-cpp/steps/02-tooling.md +12 -12
- package/skills/building-cpp/steps/03-check.md +5 -5
- package/skills/building-cpp/{project/vscode/02-settings.md → steps/04-vscode.md} +24 -6
- package/skills/developing-cpp/SKILL.md +13 -13
- package/skills/developing-cpp/references/comments/{comment-rules.md → 01-comment-rules.md} +50 -47
- package/skills/developing-cpp/references/comments/{comment-style.md → 02-style.md} +9 -7
- package/skills/developing-cpp/references/comments/examples/{declaration-class.md → 01-declaration-class.md} +2 -1
- package/skills/developing-cpp/references/comments/examples/{declaration-constructor.md → 02-declaration-constructor.md} +2 -1
- package/skills/developing-cpp/references/comments/examples/{declaration-enum.md → 03-declaration-enum.md} +3 -3
- package/skills/developing-cpp/references/comments/examples/{declaration-file.md → 04-declaration-file.md} +4 -3
- package/skills/developing-cpp/references/comments/examples/{declaration-function.md → 05-declaration-function.md} +10 -29
- package/skills/developing-cpp/references/comments/examples/{declaration-member.md → 06-declaration-member.md} +1 -0
- package/skills/developing-cpp/references/comments/examples/07-declaration-predicate.md +15 -0
- package/skills/developing-cpp/references/comments/examples/{declaration-struct.md → 08-declaration-struct.md} +1 -0
- package/skills/developing-cpp/references/comments/examples/{implementation-body.md → 09-implementation-body.md} +29 -15
- package/skills/developing-cpp/references/comments/examples/10-implementation-todo.md +17 -0
- package/skills/developing-cpp/references/comments/glossary/{comment-terms.md → 01-comment-terms.md} +8 -7
- package/skills/developing-cpp/references/design/{project-design.md → 01-project-design.md} +7 -6
- package/skills/developing-cpp/references/design/examples/{behavior-sentence.md → 01-behavior-sentence.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{coordinate-table.md → 02-coordinate-table.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{header-place.md → 03-header-place.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{library-boundary.md → 04-library-boundary.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{library-split.md → 05-library-split.md} +1 -0
- package/skills/developing-cpp/references/design/examples/{move-result.md → 06-move-result.md} +4 -10
- package/skills/developing-cpp/references/design/examples/{preview-read.md → 07-preview-read.md} +1 -0
- package/skills/developing-cpp/references/design/session-layer.md +89 -0
- package/skills/developing-cpp/references/exceptions/{throw-rules.md → 01-exception-rules.md} +9 -17
- package/skills/developing-cpp/references/exceptions/examples/{throw-boundary.md → 01-throw-boundary.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-build-mode.md → 02-throw-build-mode.md} +3 -2
- package/skills/developing-cpp/references/exceptions/examples/{throw-catch.md → 03-throw-catch.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-destructor.md → 04-throw-destructor.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-format.md → 05-throw-format.md} +1 -0
- package/skills/developing-cpp/references/exceptions/examples/{throw-message.md → 06-throw-message.md} +2 -1
- package/skills/developing-cpp/references/exceptions/examples/{throw-when.md → 07-throw-when.md} +1 -0
- package/skills/developing-cpp/references/index.md +132 -0
- package/skills/developing-cpp/references/language/glossary/{language-terms.md → 01-language-terms.md} +3 -2
- package/skills/developing-cpp/references/language/language-basics/01-objects.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/02-initialization.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/03-deduction.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/04-const.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/05-expressions.md +7 -3
- package/skills/developing-cpp/references/language/language-basics/06-functions.md +2 -1
- package/skills/developing-cpp/references/language/language-basics/07-classes.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/08-raii.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/09-templates.md +1 -0
- package/skills/developing-cpp/references/language/language-basics/{10-checklist.md → 10-language-checklist.md} +2 -0
- package/skills/developing-cpp/references/language/performance/01-measure.md +1 -0
- package/skills/developing-cpp/references/language/performance/02-complexity.md +1 -0
- package/skills/developing-cpp/references/language/performance/03-memory.md +1 -0
- package/skills/developing-cpp/references/language/performance/04-undefined-behavior.md +1 -0
- package/skills/developing-cpp/references/language/performance/05-pitfalls.md +1 -0
- package/skills/developing-cpp/references/language/performance/06-false-optimizations.md +1 -0
- package/skills/developing-cpp/references/language/performance/07-checklist.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/01-containers.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/02-access.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/03-iteration.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/04-algorithms.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/05-string.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/06-format.md +4 -1
- package/skills/developing-cpp/references/language/standard-library/07-time.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/08-random.md +2 -0
- package/skills/developing-cpp/references/language/standard-library/09-files.md +1 -0
- package/skills/developing-cpp/references/language/standard-library/{10-checklist.md → 10-library-checklist.md} +1 -0
- package/skills/developing-cpp/references/language/value-types/01-width.md +1 -0
- package/skills/developing-cpp/references/language/value-types/02-signed.md +1 -0
- package/skills/developing-cpp/references/language/value-types/03-integer-roles.md +1 -0
- package/skills/developing-cpp/references/language/value-types/04-enum.md +2 -1
- package/skills/developing-cpp/references/language/value-types/05-strong-type.md +1 -0
- package/skills/developing-cpp/references/language/value-types/06-const-method.md +1 -0
- package/skills/developing-cpp/references/language/value-types/07-nodiscard.md +1 -0
- package/skills/developing-cpp/references/language/value-types/08-comparison.md +1 -0
- package/skills/developing-cpp/references/language/value-types/09-subscript.md +2 -1
- package/skills/developing-cpp/references/language/value-types/10-float-bool.md +1 -0
- package/skills/developing-cpp/references/language/value-types/11-checklist.md +1 -0
- package/skills/developing-cpp/references/layout/01-source-layout.md +2 -1
- package/skills/developing-cpp/references/layout/02-file-template.md +4 -3
- package/skills/developing-cpp/references/layout/03-declaration-order.md +14 -4
- package/skills/developing-cpp/references/naming/{identifier-names.md → 01-identifier-names.md} +28 -9
- package/skills/developing-cpp/references/naming/examples/{naming-accessor.md → 01-naming-accessor.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/02-naming-basic.md +4 -0
- package/skills/developing-cpp/references/naming/examples/{naming-current-prefix.md → 03-naming-current-prefix.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-local.md → 04-naming-local.md} +2 -1
- package/skills/developing-cpp/references/naming/examples/{naming-lookup.md → 05-naming-lookup.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-lower-layer.md → 06-naming-lower-layer.md} +2 -2
- package/skills/developing-cpp/references/naming/examples/{naming-multiple-return.md → 07-naming-multiple-return.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-player-value.md → 08-naming-player-value.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-predicate.md → 09-naming-predicate.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-rename.md → 10-naming-rename.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-responsibility.md → 11-naming-responsibility.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-role.md → 12-naming-role.md} +1 -0
- package/skills/developing-cpp/references/naming/examples/{naming-state-change.md → 13-naming-state-change.md} +4 -4
- package/skills/developing-cpp/references/naming/glossary/01-naming-terms.md +27 -0
- package/skills/developing-cpp/references/naming/glossary/{position.md → 02-position.md} +2 -1
- package/skills/developing-cpp/references/naming/glossary/03-selection.md +23 -0
- package/skills/developing-cpp/references/naming/glossary/{square.md → 04-square.md} +3 -2
- package/skills/developing-cpp/references/naming/glossary/05-scoring.md +27 -0
- package/skills/developing-cpp/references/naming/glossary/06-difficulty.md +26 -0
- package/skills/developing-cpp/references/style/{google-cpp-style.md → 01-google-cpp-style.md} +12 -5
- package/skills/developing-cpp/scripts/checking-comments.mjs +107 -8
- package/skills/developing-cpp/steps/01-behavior.md +5 -5
- package/skills/developing-cpp/steps/02-boundary.md +6 -6
- package/skills/developing-cpp/steps/03-declaration.md +6 -6
- package/skills/developing-cpp/steps/04-implementation.md +16 -16
- package/skills/engineering/SKILL.md +14 -14
- package/skills/engineering/references/cmake/linking/01-libraries.md +7 -4
- package/skills/engineering/references/cmake/linking/02-rpath.md +1 -0
- package/skills/engineering/references/cmake/linking/03-undefined-reference.md +2 -1
- package/skills/engineering/references/cmake/linking/04-inspect.md +1 -1
- package/skills/engineering/references/cmake/modules/{functions.md → 01-functions.md} +3 -2
- package/skills/engineering/references/cmake/standards/{cxx-standard.md → 01-cxx-standard.md} +3 -2
- package/skills/engineering/references/cmake/standards/examples/{standard.md → 01-standard.md} +2 -1
- package/skills/engineering/references/cmake/standards/{README.md → index.md} +16 -15
- package/skills/engineering/references/cmake/standards/versions.md +44 -0
- package/skills/engineering/references/cmake/targets/{rules.md → 01-target-rules.md} +34 -5
- package/skills/engineering/references/cmake/targets/examples/{rpath.md → 01-rpath.md} +1 -0
- package/skills/engineering/references/cmake/testing/{ctest.md → 01-ctest.md} +3 -2
- package/skills/engineering/references/formatting/01-encoding.md +2 -1
- package/skills/engineering/references/formatting/02-clang-format.md +3 -2
- package/skills/engineering/references/formatting/03-clang-tidy.md +3 -2
- package/skills/engineering/references/formatting/04-clangd.md +2 -0
- package/skills/engineering/references/formatting/examples/{clang-format.md → 01-clang-format.md} +2 -1
- package/skills/engineering/references/formatting/examples/{clang-tidy.md → 02-clang-tidy.md} +1 -0
- package/skills/engineering/references/formatting/examples/{clangd.md → 03-clangd.md} +1 -0
- package/skills/engineering/references/index.md +32 -0
- package/skills/engineering/steps/01-targets.md +3 -3
- package/skills/engineering/steps/02-modules.md +3 -3
- package/skills/engineering/steps/03-check.md +1 -1
- package/skills/shared/budget.md +20 -0
- package/skills/{developing-cpp/references/editing/01-edit-operations.md → shared/operations.md} +7 -3
- package/skills/{developing-cpp/references/editing/02-rule-priority.md → shared/rule-priority.md} +2 -1
- package/skills/building-cpp/project/vscode/01-extensions.md +0 -28
- package/skills/developing-cpp/references/comments/examples/declaration-predicate.md +0 -14
- package/skills/developing-cpp/references/comments/examples/implementation-todo.md +0 -16
- package/skills/developing-cpp/references/naming/examples/naming-basic.md +0 -3
- package/skills/developing-cpp/references/naming/glossary/naming-terms.md +0 -23
- package/skills/engineering/references/cmake/standards/c++11/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++14/README.md +0 -48
- package/skills/engineering/references/cmake/standards/c++17/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++20/README.md +0 -50
- package/skills/engineering/references/cmake/standards/c++23/README.md +0 -50
- package/skills/engineering/references/cmake/targets/examples/glob.md +0 -22
- package/skills/engineering/references/cmake/targets/examples/target.md +0 -156
- /package/skills/engineering/{references/formatting/scripts → scripts}/checking-encoding.mjs +0 -0
|
@@ -8,20 +8,20 @@
|
|
|
8
8
|
|
|
9
9
|
- 函数保持短小,一个函数只做一件事。超过约 40 行时先找可以命名的中间步骤,不靠注释把长函数切成几段。
|
|
10
10
|
- 按「准备 → 操作 → 收尾」排列语句,用空行分组;组与组之间的空行表达阶段,同一组内的守卫与结果处理不插空行。
|
|
11
|
-
- `.cpp` 里的定义顺序跟配对头文件:先类型与常量,再自由函数,再成员函数;成员函数按类内声明顺序。头文件把构造函数、析构函数、拷贝/移动声明在成员组最前时,定义也放最前;如果头文件把它们声明在别的成员之后,仍按头文件顺序,不硬提。不为先编译重排,也不按调用频率重排。`.cpp` 里不需要外部引用的 `constexpr` 放具名命名空间,仅一个函数使用时才用函数内 `static constexpr
|
|
11
|
+
- `.cpp` 里的定义顺序跟配对头文件:先类型与常量,再自由函数,再成员函数;成员函数按类内声明顺序。头文件把构造函数、析构函数、拷贝/移动声明在成员组最前时,定义也放最前;如果头文件把它们声明在别的成员之后,仍按头文件顺序,不硬提。不为先编译重排,也不按调用频率重排。`.cpp` 里不需要外部引用的 `constexpr` 放具名命名空间,仅一个函数使用时才用函数内 `static constexpr`;函数与类型放唯一的匿名命名空间,公开函数定义放在其后;不另开具名子命名空间,也不用类的 `static` 成员来隐藏函数。见 `references/layout/03-declaration-order.md`「`.cpp` 的定义顺序」与 `references/style/01-google-cpp-style.md`。
|
|
12
12
|
- 同一文件里的函数按同一套分段约定:需要分阶段的非单表达式函数按空行分段、每段上方一句;读入、单值转换、一行输出这类一条直路的短函数不加分段注释;不能结构相近的函数一半分段、一半完全不留注释。阶段怎么分见 `references/layout/03-declaration-order.md`「函数体内的空行」。
|
|
13
|
-
- `.cpp` 的第一个 include 是自己的配对头,然后直接包含本文件用到的标准库头,不依赖公共头转发声明。包含顺序见 `references/style/google-cpp-style.md`,文件槽位见 `references/layout/02-file-template.md`。
|
|
14
|
-
- 函数体注释用 `//`,不用 `///`:体内 `///` 会接到该函数的 Doxygen 详细说明后面。重要函数按空行分阶段,每个阶段上方写一句 `//`,写这一支在检查什么,可以点明处理了哪些枚举值,不逐词翻译下一行的条件;`//` 里的枚举值不加反引号。单表达式函数(如 `IsEmpty`)不配注释;关键局部表(查表、分派表)上方写一句,说明表的角色与分组。只写删掉会让下一次修改得到错误结果、而代码本身看不出的内容;变更史留给提交说明。`.cpp`
|
|
15
|
-
- 什么时候在 `if` 上方加一句:多条独立拒绝(如 `Game::Place
|
|
16
|
-
-
|
|
17
|
-
- 失败是调用方正常结果时返回结果类型、`bool` 或 `std::optional`;函数无法完成自己的任务时抛异常,不拿异常做正常分支。Debug 与 Release 用同一套返回值与抛出条件,只有诊断详略不同。两种模式都要守的不变量用 `Check`(项目保留时),只在开发期做的自检用 `DebugCheck`;项目没有这两个宏时,`Check` 用 `std::terminate()` 兜底,`DebugCheck` 用 `assert`;`assert` 在 Release 不求值,不能代替 `Check`。`Check` 不是 `[[noreturn]]`,条件成立时正常返回;`DebugCheck` 的参数在 Release 不求值,不能放入有副作用的表达式。捕获时按 `const` 引用,只处理能处理的类型,其余继续抛。异常类型、消息格式与「不抛的边界」见 `references/exceptions/
|
|
18
|
-
- 参数校验、调用方状态检查与正常结果返回的次序见 `references/exceptions/
|
|
13
|
+
- `.cpp` 的第一个 include 是自己的配对头,然后直接包含本文件用到的标准库头,不依赖公共头转发声明。包含顺序见 `references/style/01-google-cpp-style.md`,文件槽位见 `references/layout/02-file-template.md`。
|
|
14
|
+
- 函数体注释用 `//`,不用 `///`:体内 `///` 会接到该函数的 Doxygen 详细说明后面。重要函数按空行分阶段,每个阶段上方写一句 `//`,写这一支在检查什么,可以点明处理了哪些枚举值,不逐词翻译下一行的条件;`//` 里的枚举值不加反引号。单表达式函数(如 `IsEmpty`)不配注释;关键局部表(查表、分派表)上方写一句,说明表的角色与分组。只写删掉会让下一次修改得到错误结果、而代码本身看不出的内容;变更史留给提交说明。`.cpp` 里只在 .cpp 出现的函数才写 `///`:有参数或返回值时写完整契约(`@param`、`@return`、`@pre`),与头文件声明同一套标签;头文件已声明的定义处不写 `///`;类方法定义不重复声明处已有的事实。
|
|
15
|
+
- 什么时候在 `if` 上方加一句:多条独立拒绝(如 `Game::Place`)不逐条注释,只有失败结果的优先级需要说明时在第一条 `if` 上方写一句总起;成功写入前一句;只有次序依赖的一对 `if` 在第一个上方说明;循环上方已有阶段说明时,循环里的 `if` 不再加;单表达式谓词不加。
|
|
16
|
+
- 枚举全覆盖不写 `default`,单条 `return` 不加花括号,`std::unreachable()` 紧跟 `switch` 右花括号;细节见 `references/language/language-basics/05-expressions.md`。
|
|
17
|
+
- 失败是调用方正常结果时返回结果类型、`bool` 或 `std::optional`;函数无法完成自己的任务时抛异常,不拿异常做正常分支。Debug 与 Release 用同一套返回值与抛出条件,只有诊断详略不同。两种模式都要守的不变量用 `Check`(项目保留时),只在开发期做的自检用 `DebugCheck`;项目没有这两个宏时,`Check` 用 `std::terminate()` 兜底,`DebugCheck` 用 `assert`;`assert` 在 Release 不求值,不能代替 `Check`。`Check` 不是 `[[noreturn]]`,条件成立时正常返回;`DebugCheck` 的参数在 Release 不求值,不能放入有副作用的表达式。捕获时按 `const` 引用,只处理能处理的类型,其余继续抛。异常类型、消息格式与「不抛的边界」见 `references/exceptions/01-exception-rules.md`。
|
|
18
|
+
- 参数校验、调用方状态检查与正常结果返回的次序见 `references/exceptions/01-exception-rules.md` 的「检查次序」:先整局状态,再进行中的玩家,最后交给下层检查坐标与占用,下层检查不重复。改完 `throw` 再走同文件的「检查清单」:异常类型、消息标签、跨行消息先存变量、不吞异常。
|
|
19
19
|
- 声明 `noexcept` 前核对函数体:出现 `at()` 或其他可能抛出的调用就去掉。越界用 `at()` 抛 `std::out_of_range`,这个函数就不能标 `noexcept`。普通查询和返回结果枚举的函数,不因为当前函数体不抛就补 `noexcept`;它留给移动、交换、析构,以及已经标上的纯谓词。
|
|
20
20
|
- 组合输出用 `std::format`,再写入 `std::cout` / `std::cerr`;库实现里不直接打印。C++23 且库支持时程序边界可用 `std::print`,C++20 及更早没有。
|
|
21
21
|
- 转换用具名转换 `static_cast` / `std::bit_cast`,不用 C 风格强制转换。
|
|
22
22
|
- 所有权用 `std::unique_ptr`;禁止裸 `new` / `delete`,没有共享所有权的理由时不用 `std::shared_ptr`。
|
|
23
23
|
- 只改注释时,不改可观察行为;只改实现时,不改公共声明。两者同时需要时,先改声明,再改实现。
|
|
24
|
-
- 清空成员数组:元素类型只提供赋值入口时(如 `Square::SetValue`),容器的 `ClearSquare` 调用 `SetValue(kEmpty)`,`Clear` 再逐格调用 `ClearSquare`;不要把清空操作放回值对象。不要直接写 `squares_ = {}`,也不要从外部把枚举赋成空值。撤销只回退受影响的那一处,不清空整个容器再重放全部历史,见 `references/design/project-design.md` 的「撤销与回退」。
|
|
24
|
+
- 清空成员数组:元素类型只提供赋值入口时(如 `Square::SetValue`),容器的 `ClearSquare` 调用 `SetValue(kEmpty)`,`Clear` 再逐格调用 `ClearSquare`;不要把清空操作放回值对象。不要直接写 `squares_ = {}`,也不要从外部把枚举赋成空值。撤销只回退受影响的那一处,不清空整个容器再重放全部历史,见 `references/design/01-project-design.md` 的「撤销与回退」。
|
|
25
25
|
- 默认构造只做「建立初值」时用成员初值(如 `squares_{}`),不在构造函数里再调一遍 `Clear()`;`Clear()` 只负责把已经写入的值清空为 `kEmpty`。
|
|
26
26
|
|
|
27
27
|
## 情况
|
|
@@ -36,15 +36,15 @@
|
|
|
36
36
|
|
|
37
37
|
## 交回构建
|
|
38
38
|
|
|
39
|
-
实现改完,先对照配对头文件自检:每个声明都有定义,定义顺序与声明顺序一致;新增或改动的函数按同一套分段约定,需要分阶段的都有阶段注释与空行;只改过语言细节时再过对应目录的完成清单(`references/language/value-types/11-checklist.md`、`language-basics/10-checklist.md`、`standard-library/10-checklist.md`、`performance/07-checklist.md`);行宽与缩进以工程根 `.clang-format` 为准,注释版式见 `references/comments/
|
|
39
|
+
实现改完,先对照配对头文件自检:每个声明都有定义,定义顺序与声明顺序一致;新增或改动的函数按同一套分段约定,需要分阶段的都有阶段注释与空行;只改过语言细节时再过对应目录的完成清单(`references/language/value-types/11-checklist.md`、`language-basics/10-language-checklist.md`、`standard-library/10-library-checklist.md`、`performance/07-checklist.md`);行宽与缩进以工程根 `.clang-format` 为准,注释版式见 `references/comments/02-style.md`。再跑 `node <skill-dir>/scripts/checking-declaration-order.mjs --root .`(`<skill-dir>` 换成插件 `developing-cpp` 的实际目录),有乱序先修再交回下游:需要新增或移动源文件时,先由 `engineering` 的 `steps/01-targets.md` 把文件显式写进 target;target 齐了再由 `building-cpp` 的 `steps/01-build.md` configure、构建,最后走 `steps/03-check.md`。不要只改完函数体就宣称完成。
|
|
40
40
|
|
|
41
41
|
## 正反例指针
|
|
42
42
|
|
|
43
|
-
- 实现注释复述代码、分组混乱:`references/comments/examples/implementation-body.md`。
|
|
43
|
+
- 实现注释复述代码、分组混乱:`references/comments/examples/09-implementation-body.md`。
|
|
44
44
|
- 已经证明非负的坐标把下标收成 `std::size_t` 再 `[]`,不转成 `int`:`references/language/value-types/09-subscript.md`。
|
|
45
|
-
- 越界消息的函数名、文件与行列都取自调用点:`references/exceptions/
|
|
46
|
-
- 多个入口重复同一范围检查:抽私有函数,`source_location` 默认参数取调用点,见 `references/exceptions/
|
|
47
|
-
- 为了保住 `noexcept` 再包一层只转发下标的私有函数:`references/exceptions/
|
|
48
|
-
- 用 `static_cast<void>` 丢弃 `[[nodiscard]]` 的落子结果,或丢掉调用方给的一手、在 `Game` 内重新拼装:`references/design/examples/move-result.md`。
|
|
49
|
-
- 异常类型与结果类型混用:`references/exceptions/examples/throw-when.md`。
|
|
50
|
-
- `std::format` 与流输出混用得当:`references/exceptions/examples/throw-message.md`。
|
|
45
|
+
- 越界消息的函数名、文件与行列都取自调用点:`references/exceptions/01-exception-rules.md`「消息」的 `std::source_location` 用法。
|
|
46
|
+
- 多个入口重复同一范围检查:抽私有函数,`source_location` 默认参数取调用点,见 `references/exceptions/01-exception-rules.md`「重复的入口检查」。
|
|
47
|
+
- 为了保住 `noexcept` 再包一层只转发下标的私有函数:`references/exceptions/01-exception-rules.md`「不抛的边界」。
|
|
48
|
+
- 用 `static_cast<void>` 丢弃 `[[nodiscard]]` 的落子结果,或丢掉调用方给的一手、在 `Game` 内重新拼装:`references/design/examples/06-move-result.md`。
|
|
49
|
+
- 异常类型与结果类型混用:`references/exceptions/examples/07-throw-when.md`。
|
|
50
|
+
- `std::format` 与流输出混用得当:`references/exceptions/examples/06-throw-message.md`。
|
|
@@ -7,7 +7,7 @@ metadata:
|
|
|
7
7
|
|
|
8
8
|
# engineering
|
|
9
9
|
|
|
10
|
-
本技能管两件事:CMake 文件与 target 契约,以及编码与排版工具配置。函数体、类型、命名、异常与源码注释只开 `developing-cpp`;构建目录、编译器、入口脚本与运行检查开 `building-cpp
|
|
10
|
+
本技能管两件事:CMake 文件与 target 契约,以及编码与排版工具配置。函数体、类型、命名、异常与源码注释只开 `developing-cpp`;构建目录、编译器、入口脚本与运行检查开 `building-cpp`。加载顺序与层表见 [budget.md](../shared/budget.md)。
|
|
11
11
|
|
|
12
12
|
## 适用场景
|
|
13
13
|
|
|
@@ -19,7 +19,7 @@ metadata:
|
|
|
19
19
|
|
|
20
20
|
## 三种操作
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
一次只选一种操作,范围(单点、整段)是任务属性;判据、边界与交接见共用入口 [operations.md](../shared/operations.md)。本技能从 [01-targets.md](steps/01-targets.md) 进;四类改动是域,不是操作。
|
|
23
23
|
|
|
24
24
|
| 操作 | 什么时候用 | 从哪步进 |
|
|
25
25
|
| --- | --- | --- |
|
|
@@ -46,28 +46,28 @@ metadata:
|
|
|
46
46
|
|
|
47
47
|
| 要做的事 | 打开 |
|
|
48
48
|
| --- | --- |
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
49
|
+
| 不知道开哪一份条文 | `references/index.md` |
|
|
50
|
+
| 定 target、include、链接、输出目录与警告 | `references/cmake/targets/01-target-rules.md`;案例在 `references/cmake/targets/examples/` |
|
|
51
|
+
| 定语言标准与档位 | `references/cmake/standards/01-cxx-standard.md`;五档细节在 `references/cmake/standards/versions.md` |
|
|
52
|
+
| 抽 CMake 函数与模块 | `references/cmake/modules/01-functions.md` |
|
|
52
53
|
| 链接方式、rpath、undefined reference、产物核对 | 按问题只开一份:`references/cmake/linking/01-libraries.md`、`02-rpath.md`、`03-undefined-reference.md`、`04-inspect.md` |
|
|
53
|
-
| CTest 注册、断言与用例拆分 | `references/cmake/testing/ctest.md` |
|
|
54
|
+
| CTest 注册、断言与用例拆分 | `references/cmake/testing/01-ctest.md` |
|
|
54
55
|
| 编码、BOM 与行尾 | `references/formatting/01-encoding.md` |
|
|
55
|
-
| clang-format | `references/formatting/02-clang-format.md`;案例 `references/formatting/examples/clang-format.md` |
|
|
56
|
-
| clang-tidy 与检查分级 | `references/formatting/03-clang-tidy.md`;案例 `references/formatting/examples/clang-tidy.md` |
|
|
57
|
-
| clangd 与编辑器补全 | `references/formatting/04-clangd.md`;案例 `references/formatting/examples/clangd.md` |
|
|
56
|
+
| clang-format | `references/formatting/02-clang-format.md`;案例 `references/formatting/examples/01-clang-format.md` |
|
|
57
|
+
| clang-tidy 与检查分级 | `references/formatting/03-clang-tidy.md`;案例 `references/formatting/examples/02-clang-tidy.md` |
|
|
58
|
+
| clangd 与编辑器补全 | `references/formatting/04-clangd.md`;案例 `references/formatting/examples/03-clangd.md` |
|
|
58
59
|
| 可复制的 CMake 函数 | `references/cmake/assets/CompileSettings.cmake`、`references/cmake/assets/LinkSettings.cmake` |
|
|
60
|
+
| 操作判不准、规则冲突 | `../shared/operations.md`、`../shared/rule-priority.md` |
|
|
59
61
|
|
|
60
62
|
## 加载预算
|
|
61
63
|
|
|
62
|
-
|
|
63
|
-
- 条文只开该步点名的一份;同号案例留到下一次激活;target 案例先列 `references/cmake/targets/examples/`,再按问题选一份;排版工具一次只开入口表里的那一份。
|
|
64
|
-
- 标准档只打开项目技能声明的那一档,没有声明时用本技能已有的新工程默认,不把其余标准档读进来。
|
|
64
|
+
加载预算见 [budget.md](../shared/budget.md);engineering 的步骤固定 3 份。
|
|
65
65
|
|
|
66
66
|
项目技能列出了检查命令时只跑那一条,没有时按 `steps/03-check.md` 的 configure 与构建命令跑;退出码为 0 后停在这一步,不再继续走没有失败的步骤。五档标准的语言设施、工具映射与降档由 `references/cmake/standards/` 维护;本技能只负责这些标准在 CMake 里怎么写,以及三份工具配置各自的最低版本。
|
|
67
67
|
|
|
68
68
|
## 四类改动
|
|
69
69
|
|
|
70
|
-
四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见
|
|
70
|
+
四类改动是操作内部的域:操作定入口,域定层次。四域的定义、边界与次序见 [operations.md](../shared/operations.md);engineering 的一次改动混了两类时,按「内容 → 结构 → 版式 → 措辞」拆开做,前一类落定并经检查再进下一类。
|
|
71
71
|
|
|
72
72
|
| 类型 | 典型请求 | 入口步骤 |
|
|
73
73
|
| --- | --- | --- |
|
|
@@ -81,7 +81,7 @@ metadata:
|
|
|
81
81
|
- [ ] target 图显式:程序 target 叫 `app`,库 target 用组件名,程序链接库,库的公共 include 用 `PUBLIC`;没有全局 include、全局编译选项或 GLOB。
|
|
82
82
|
- [ ] 每个 target 的标准来自 `environment.json`;`target_compile_features` 与 `CXX_STANDARD`、`CXX_STANDARD_REQUIRED ON`、`CXX_EXTENSIONS OFF` 同时存在,live 的 `compile_commands.json` 中每个 target 的 `-std=` 都与声明一致,且每个 target 只有一条、不同值即失败,不是 `gnu++NN`。
|
|
83
83
|
- [ ] 复用的 CMake 函数放在工程根的 `cmake/` 模块里(模板源在 `references/cmake/assets/`),文件名用 UpperCamelCase,函数名用 `<ModuleName>_` 加 PascalCase,有目标与参数校验,根 `CMakeLists.txt` 通过 `CMAKE_MODULE_PATH` 导入;没有重复片段和未使用的旧模块。
|
|
84
|
-
- [ ] 公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` / `:keyword` 标参数;不写 `#[[.rst:` 与 `.. command::`,完整写法见 `references/cmake/targets/rules.md`;函数组之间用 `#---`,不画 `#===...===#` 方框。
|
|
84
|
+
- [ ] 公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` / `:keyword` 标参数;不写 `#[[.rst:` 与 `.. command::`,完整写法见 `references/cmake/targets/01-target-rules.md`;函数组之间用 `#---`,不画 `#===...===#` 方框。
|
|
85
85
|
- [ ] `CMakeLists.txt` 与 `*.cmake` 用 UTF-8 无 BOM、LF、2 空格缩进、不用 tab;行宽按团队约定,默认 80 列。
|
|
86
86
|
- [ ] 编码与排版工具各管一段:`.clang-format` 管空白与包含顺序,`.clang-tidy` 管检查分级,`.clangd` 管编辑器补全;三份都不把标准写死成与 `environment.json` 冲突的值,也不把 clang-format 塞进构建脚本。
|
|
87
87
|
- [ ] configure 与构建通过,构建产物不落在源码目录;没有改源码语义,也没有覆盖已有工程文件。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:链接与库边界;预算:一次只开这一份(62 行),不自动串联。 -->
|
|
1
2
|
# 链接与库边界
|
|
2
3
|
|
|
3
4
|
## 四个阶段
|
|
@@ -21,7 +22,7 @@
|
|
|
21
22
|
- 普通函数的定义放 `.cpp`;在头文件里写非 `inline` 函数定义,多个翻译单元包含时会重复定义。
|
|
22
23
|
- 类定义放头文件;成员函数在类外定义时写 `ClassName::`,定义放 `.cpp`。
|
|
23
24
|
- 只用到声明时不要包含完整定义;前置声明可以减少编译依赖,但不能替代需要完整类型的场景(继承、成员对象、按值返回)。
|
|
24
|
-
- 每个头文件自包含:单独编译一个只包含该头文件的 `.cpp`
|
|
25
|
+
- 每个头文件自包含:单独编译一个只包含该头文件的 `.cpp` 应通过。这是编译单元边界的要求,不是链接要求。用路径式 `#define` 守卫防止重复包含,不用 `#pragma once`。
|
|
25
26
|
|
|
26
27
|
## 静态库与共享库
|
|
27
28
|
|
|
@@ -35,13 +36,15 @@
|
|
|
35
36
|
- 共享库的 ABI 包括类布局、虚表、标准库类型和编译器选项;不同编译器或 `-stdlib` 混用可能链接成功但运行崩溃。
|
|
36
37
|
- 一个项目里不要同时链接两套标准库(libstdc++ 与 libc++);编译器、clangd、库和可执行文件必须一致。
|
|
37
38
|
|
|
38
|
-
##
|
|
39
|
+
## 构建脚本里的建议顺序
|
|
40
|
+
|
|
41
|
+
这是构建入口的推荐顺序,不是链接器的硬性要求:
|
|
39
42
|
|
|
40
43
|
1. 配置:CMake 生成构建系统,导出编译数据库。
|
|
41
44
|
2. 编译 + 链接:构建所有 target。
|
|
42
45
|
3. 产物检查:确认 `bin/app`、`lib/`、编译数据库存在。
|
|
43
|
-
4.
|
|
44
|
-
5.
|
|
46
|
+
4. 测试:`ctest` 跑注册的测试。
|
|
47
|
+
5. 运行:用项目入口命令启动,检查退出码和输出。
|
|
45
48
|
|
|
46
49
|
不要用“链接成功”代替“运行成功”;也不要用“测试通过”代替“产物存在”。
|
|
47
50
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:undefined reference 分诊;预算:一次只开这一份(20 行),不自动串联。 -->
|
|
1
2
|
# undefined reference 分诊
|
|
2
3
|
|
|
3
4
|
## `undefined reference` 分诊
|
|
@@ -6,7 +7,7 @@
|
|
|
6
7
|
| --- | --- | --- |
|
|
7
8
|
| 链接器说某个成员函数未定义 | 声明了但没写定义,或 `.cpp` 没加入 target | 补定义,或把源文件加入 `target_sources` |
|
|
8
9
|
| 只有某个平台失败 | 条件编译把定义排除了 | 检查宏和平台分支,保证每个平台都有定义 |
|
|
9
|
-
| 第三方库符号缺失 |
|
|
10
|
+
| 第三方库符号缺失 | 没链接库,或静态库相互依赖顺序不对 | `target_link_libraries` 加库;CMake 传播 target 依赖,静态库相互依赖时仍要检查顺序 |
|
|
10
11
|
| C++ 符号被当成 C 符号 | 头文件缺少 `extern "C"` | C 接口头加 `extern "C"`,C++ 调用方也可见 |
|
|
11
12
|
| 模板成员未定义 | 模板定义在 `.cpp`,实例化点看不到 | 模板定义移到头文件,或显式实例化 |
|
|
12
13
|
| 静态库中的目标文件没被拉入 | 链接器只取被引用符号所在的目标文件 | 确认符号确实被引用,或改用对象库/共享库 |
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:验收:file 与 ldd;预算:一次只开这一份(20 行),不自动串联。 -->
|
|
1
2
|
# 验收:file 与 ldd
|
|
2
3
|
|
|
3
4
|
## 验收:`file` 与 `ldd`
|
|
@@ -18,4 +19,3 @@ ldd build/clang/bin/app
|
|
|
18
19
|
|
|
19
20
|
- [`file(1)`](https://man7.org/linux/man-pages/man1/file.1.html):识别文件格式、架构与位数。
|
|
20
21
|
- [`ldd(1)`](https://man7.org/linux/man-pages/man1/ldd.1.html):动态库依赖解析与 `not found` 的含义。
|
|
21
|
-
- [CMake: `add_custom_command`](https://cmake.org/cmake/help/latest/command/add_custom_command.html):把产物检查接进构建流程。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:CMake 模块与函数;预算:一次只开这一份(108 行),不自动串联。 -->
|
|
1
2
|
# CMake 模块与函数
|
|
2
3
|
|
|
3
4
|
目标:同一段构建逻辑只有一份权威,函数可导入、可校验、可测试,目标目录只表达差异。
|
|
@@ -22,7 +23,7 @@ project/
|
|
|
22
23
|
LinkSettings.cmake
|
|
23
24
|
component/
|
|
24
25
|
CMakeLists.txt
|
|
25
|
-
|
|
26
|
+
app/
|
|
26
27
|
CMakeLists.txt
|
|
27
28
|
```
|
|
28
29
|
|
|
@@ -75,7 +76,7 @@ endfunction()
|
|
|
75
76
|
|
|
76
77
|
## 契约注释
|
|
77
78
|
|
|
78
|
-
公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` 标位置参数、`:keyword` 标关键字参数;不写 `#[[.rst:` 与 `.. command::`,那是进 CMake 手册的模块才用的标记。同一文件的函数组之间用一条 `#---` 分隔,行注释只写原因,不画 `#===...===#` 方框。完整写法见 `../targets/rules.md`。
|
|
79
|
+
公开函数上方写中文 `#` 契约:一句功能、空行、边界,再用 `:param` 标位置参数、`:keyword` 标关键字参数;不写 `#[[.rst:` 与 `.. command::`,那是进 CMake 手册的模块才用的标记。同一文件的函数组之间用一条 `#---` 分隔,行注释只写原因,不画 `#===...===#` 方框。完整写法见 `../targets/01-target-rules.md`。
|
|
79
80
|
|
|
80
81
|
## 测试
|
|
81
82
|
|
package/skills/engineering/references/cmake/standards/{cxx-standard.md → 01-cxx-standard.md}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:C++ 标准与 CMake;预算:一次只开这一份(68 行),不自动串联。 -->
|
|
1
2
|
# C++ 标准与 CMake
|
|
2
3
|
|
|
3
4
|
目标:一个 target 只声明一个标准,声明在 target 上,编译数据库里的实际参数与声明一致。
|
|
@@ -11,8 +12,8 @@ CMake 有两套相关机制,必须同时写:
|
|
|
11
12
|
|
|
12
13
|
| `standard` | meta-feature | `CXX_STANDARD` | `__cplusplus` | CMake 最低版本 |
|
|
13
14
|
| --- | --- | --- | --- | --- |
|
|
14
|
-
| `c++11` | `cxx_std_11` | `11` | `201103L` | 3.
|
|
15
|
-
| `c++14` | `cxx_std_14` | `14` | `201402L` | 3.
|
|
15
|
+
| `c++11` | `cxx_std_11` | `11` | `201103L` | 3.1 |
|
|
16
|
+
| `c++14` | `cxx_std_14` | `14` | `201402L` | 3.1 |
|
|
16
17
|
| `c++17` | `cxx_std_17` | `17` | `201703L` | 3.8 |
|
|
17
18
|
| `c++20` | `cxx_std_20` | `20` | `202002L` | 3.12 |
|
|
18
19
|
| `c++23` | `cxx_std_23` | `23` | `202302L` | 3.20 |
|
package/skills/engineering/references/cmake/standards/examples/{standard.md → 01-standard.md}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:正反例:标准只写一半;预算:一次只开这一份(19 行),不自动串联。 -->
|
|
1
2
|
# 正反例:标准只写一半
|
|
2
3
|
|
|
3
4
|
**差**:
|
|
@@ -8,7 +9,7 @@ target_compile_features(app PRIVATE cxx_std_20)
|
|
|
8
9
|
set_target_properties(app PROPERTIES CXX_STANDARD 20)
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
问题:meta-feature 只保证“至少”,`CXX_STANDARD`
|
|
12
|
+
问题:meta-feature 只保证“至少”,`CXX_STANDARD` 又允许静默降级,实际标准可能不是 20。
|
|
12
13
|
|
|
13
14
|
**好**:
|
|
14
15
|
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:语言标准档案;预算:一次只开这一份(165 行),不自动串联。 -->
|
|
1
2
|
# 语言标准档案
|
|
2
3
|
|
|
3
4
|
本工作流默认 **C++23**,但一个工程只选一个 `standard`,不为同一份源码承诺“同时兼容 C++11–C++23”。标准是项目级事实,写在项目的 `environment.json`(本书在 `.agents/skills/cpp-workflow-project/environment.json`)。
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
各档的编译器下限、能用/不能假设、降档要改什么集中在 [versions.md](versions.md);`c++11/`–`c++23/` 只保留这一档的 `cmake-snippet.cmake`。模板仍然只有一套公共骨架,靠 `__cplusplus` 条件选择实现,不复制五份模板。
|
|
6
7
|
|
|
7
|
-
Google C++ Style Guide 上游仍写 “target C++20”,本工作流默认 C++23 是一处明确偏离;Google 的排版、命名、头文件和异常之外的规则不变。异常政策仍按 [
|
|
8
|
+
Google C++ Style Guide 上游仍写 “target C++20”,本工作流默认 C++23 是一处明确偏离;Google 的排版、命名、头文件和异常之外的规则不变。异常政策仍按 [01-exception-rules.md](../../../../developing-cpp/references/exceptions/01-exception-rules.md)。
|
|
8
9
|
|
|
9
10
|
## 选择标准
|
|
10
11
|
|
|
11
|
-
| 标准 |
|
|
12
|
+
| 标准 | 差异 | 一句话 |
|
|
12
13
|
| --- | --- | --- |
|
|
13
|
-
| C++11 | [
|
|
14
|
-
| C++14 | [
|
|
15
|
-
| C++17 | [
|
|
16
|
-
| C++20 | [
|
|
17
|
-
| C++23 | [
|
|
14
|
+
| C++11 | [versions.md#c11](versions.md#c11) | 老工具链、老库仍要维护时的最低档 |
|
|
15
|
+
| C++14 | [versions.md#c14](versions.md#c14) | 需要 `make_unique`、泛型 lambda,但还不想上 C++17 |
|
|
16
|
+
| C++17 | [versions.md#c17](versions.md#c17) | 需要 `string_view`、`optional`、`if constexpr` 的稳定基线 |
|
|
17
|
+
| C++20 | [versions.md#c20](versions.md#c20) | 需要 concepts、ranges、`std::format` 的现代基线 |
|
|
18
|
+
| C++23 | [versions.md#c23](versions.md#c23) | 本工作流默认;需要 `print`、`expected` 等设施时选它 |
|
|
18
19
|
|
|
19
|
-
新工程写 `c++23`;已有工程按现有 `CMakeLists.txt`
|
|
20
|
+
新工程写 `c++23`;已有工程按现有 `CMakeLists.txt` 和编译器能力选,不为了“统一”擅自升降。降档前先读 `versions.md` 对应一节的“不能假设”和“降档要改什么”。
|
|
20
21
|
|
|
21
22
|
## 三个规划粒度
|
|
22
23
|
|
|
@@ -24,7 +25,7 @@ Google C++ Style Guide 上游仍写 “target C++20”,本工作流默认 C++2
|
|
|
24
25
|
| --- | --- | --- |
|
|
25
26
|
| 项目 | 本页选择表、编译器/库门槛 | `environment.json` 的 `standard`,以及“为什么选这档” |
|
|
26
27
|
| target | 该档的 `cmake-snippet.cmake` | `cxx_std_*`、`CXX_STANDARD`、`CXX_STANDARD_REQUIRED`、`CXX_EXTENSIONS` |
|
|
27
|
-
| 代码/工具 |
|
|
28
|
+
| 代码/工具 | `versions.md` 的“能用/不能假设/降档” | 设施替换、`.clang-format` 档位、`.clangd` 不写 `-std` |
|
|
28
29
|
| 验证 | 本页验证矩阵、`scripts/checking-standard-matrix.sh` | configure/build/CTest 和 `compile_commands.json` 的精确 `-std` |
|
|
29
30
|
|
|
30
31
|
每个标准目录都按这四层写;不要只在项目层改 `standard`,却在 target 层留着 C++23 的 `cxx_std_23`。
|
|
@@ -69,7 +70,7 @@ set_target_properties(app PROPERTIES
|
|
|
69
70
|
```
|
|
70
71
|
|
|
71
72
|
- `cxx_std_23` 是“至少”,会向依赖它的 target 传播。
|
|
72
|
-
- `CXX_STANDARD` 是请求值;`CXX_STANDARD_REQUIRED ON`
|
|
73
|
+
- `CXX_STANDARD` 是请求值;`CXX_STANDARD_REQUIRED ON` 防止编译器不支持时静默降级。
|
|
73
74
|
- `CXX_EXTENSIONS OFF` 把 `-std=gnu++23` 收成 `-std=c++23`。
|
|
74
75
|
- configure 后读 `compile_commands.json` 中每个 target 的 `-std=`;每个 target 只能有一条,必须是 `-std=c++NN`,不能是 `gnu++NN`,不同值即失败。
|
|
75
76
|
- CMake 最低 3.20(模板统一要求);只单独使用低档片段时,C++11/14 的 `cxx_std_*` meta-feature 最低 3.1,C++17 为 3.8,C++20 为 3.12。C++23 的 `CXX_STANDARD 23` 自 3.20 才有。
|
|
@@ -151,7 +152,7 @@ target_link_options(app PRIVATE -stdlib=libc++)
|
|
|
151
152
|
|
|
152
153
|
增加 C++26 或更高标准时,不复制模板,按这个顺序做:
|
|
153
154
|
|
|
154
|
-
1.
|
|
155
|
+
1. 在 `versions.md` 增加 C++26 一节,新建 `standards/c++26/cmake-snippet.cmake` 并改数字。
|
|
155
156
|
2. 更新本页矩阵和 `checking-environment.mjs` 的 `STANDARDS`。
|
|
156
157
|
3. 确认 CMake 的 `CXX_STANDARD 26`、clang-format 的 `Standard` 能力、编译器/标准库门槛。
|
|
157
158
|
4. 在四套模板 × 新档上跑 configure/build/CTest,并在 `compile_commands.json` 核对 `-std=c++26`。
|
|
@@ -159,7 +160,7 @@ target_link_options(app PRIVATE -stdlib=libc++)
|
|
|
159
160
|
|
|
160
161
|
## 相关文件
|
|
161
162
|
|
|
162
|
-
- [environment.md](../../../../building-cpp/references/environment.md):四轴声明与校验。
|
|
163
|
-
- [cxx-standard.md](cxx-standard.md):C++11–C++23 在 CMake 里的两层声明与验证。
|
|
164
|
-
- [clang-tidy.md](../../formatting/03-clang-tidy.md):clang-format / clang-tidy / clangd 分工。
|
|
163
|
+
- [02-environment.md](../../../../building-cpp/references/02-environment.md):四轴声明与校验。
|
|
164
|
+
- [01-cxx-standard.md](01-cxx-standard.md):C++11–C++23 在 CMake 里的两层声明与验证。
|
|
165
|
+
- [03-clang-tidy.md](../../formatting/03-clang-tidy.md):clang-format / clang-tidy / clangd 分工。
|
|
165
166
|
- [01-build.md](../../../../building-cpp/steps/01-build.md):定构建步骤。
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:C++11–C++23 各档差异;预算:一次只开这一份(43 行),不自动串联。 -->
|
|
2
|
+
# 各标准差异
|
|
3
|
+
|
|
4
|
+
本页只列每档相对前一档多出什么、不能假设什么、降到这一档要改什么。选择表、共用矩阵、CMake/clang-format/clangd 共用规则与验证矩阵在 [index.md](index.md);每档的 CMake 片段在 `c++NN/cmake-snippet.cmake`。
|
|
5
|
+
|
|
6
|
+
## C++11
|
|
7
|
+
|
|
8
|
+
- 能用:`auto`、范围 `for`、lambda、右值引用与移动语义、`std::unique_ptr`/`shared_ptr`、`std::thread`/`chrono`、`enum class`、`override`/`final`、变参模板、受限 `constexpr`、`std::array`、`unordered_map`/`unordered_set`。
|
|
9
|
+
- 不能假设:`std::make_unique`、泛型 lambda、变量模板、返回类型推导、`std::string_view`、`std::optional`、`std::variant`、`if constexpr`、结构化绑定、`[[nodiscard]]`、`std::filesystem`、`std::format`、`std::print`;不要用 C++14 的放宽 `constexpr` 写循环或多语句函数。
|
|
10
|
+
- 降档/升级:这是最低档;从 C++14 降到这里,先去掉 `std::make_unique`、泛型 lambda、返回类型推导和变量模板。`std::unique_ptr<T>(new T(...))` 只作过渡,不要在新代码里扩散。
|
|
11
|
+
- 验证:`compile_commands.json` 的最后一个 `-std=` 必须是 `-std=c++11`,不能是 `gnu++11`;模板的 `__cplusplus` 分支走字符串拼接。
|
|
12
|
+
- 片段:[cmake-snippet.cmake](c++11/cmake-snippet.cmake)。
|
|
13
|
+
|
|
14
|
+
## C++14
|
|
15
|
+
|
|
16
|
+
- 能用:C++11 的全部内容;`std::make_unique`、泛型 lambda、变量模板、返回类型推导、二进制字面量、数字分隔符、放宽的 `constexpr`、`std::integer_sequence`。
|
|
17
|
+
- 不能假设:`std::string_view`、`std::optional`、`std::variant`、`if constexpr`、结构化绑定、`[[nodiscard]]`、`std::filesystem`、`std::format`、`std::print`;不要把 C++17 的写法靠编译器扩展通过。
|
|
18
|
+
- 降档/升级:从 C++17 降到这里,把 `string_view` 改成 `const std::string&`,把 `optional` 改成 `bool` + 输出参数或项目结果类型,把 `if constexpr` 改成标签分派或重载。升级到 C++17 后也不要立刻把公共接口全改成 `string_view`,先看调用方生命周期。
|
|
19
|
+
- 验证:`compile_commands.json` 的最后一个 `-std=` 必须是 `-std=c++14`;模板在 C++14 下走字符串拼接。
|
|
20
|
+
- 片段:[cmake-snippet.cmake](c++14/cmake-snippet.cmake)。
|
|
21
|
+
|
|
22
|
+
## C++17
|
|
23
|
+
|
|
24
|
+
- 能用:C++14 的全部内容;`std::string_view`、`std::optional`、`std::variant`、`std::any`、`if constexpr`、结构化绑定、`[[nodiscard]]`、内联变量、嵌套命名空间、`std::filesystem`、并行算法(库实现和链接方式另看)。
|
|
25
|
+
- 不能假设:concepts、ranges、`std::format`、`std::span`、`std::bit_cast`、`std::print`、`std::expected`、`std::stacktrace`、`= default` 的比较运算符;`std::filesystem` 在 GCC 8 需要额外链接 `stdc++fs`,GCC 9 起才稳定。
|
|
26
|
+
- 降档/升级:从 C++20 降到这里,把 concepts 改成 `enable_if`/重载,把 ranges 改成迭代器算法,把 `std::format` 改成 `std::ostringstream`,把 `= default` 的比较运算符改回结构体外的手写自由函数。升级到 C++20 后先确认 `std::format` 的库门槛(libstdc++ 13+ / libc++ 14+),不要只看编译器版本。
|
|
27
|
+
- 验证:`compile_commands.json` 的最后一个 `-std=` 必须是 `-std=c++17`;模板在 C++17 下仍走字符串拼接。
|
|
28
|
+
- 片段:[cmake-snippet.cmake](c++17/cmake-snippet.cmake)。
|
|
29
|
+
|
|
30
|
+
## C++20
|
|
31
|
+
|
|
32
|
+
- 能用:C++17 的全部内容;concepts、requires、ranges、`std::span`、`std::bit_cast`、`std::source_location`、`std::format`、协程、`std::jthread`、三路比较;调用方需要按成员逐项比较时写 `bool operator==(const T&) const = default`,C++23 沿用;模块语法可用,但工具链支持不完整,模板不使用。
|
|
33
|
+
- 不能假设:`std::print`、`std::expected`、`std::stacktrace`、`if consteval`、显式对象参数;`std::format` 不只看语言核心:libstdc++ 13+,libc++ 14+ 实现完成,但特性宏到 19 才稳定;模块、协程的构建支持因编译器/构建系统而异。
|
|
34
|
+
- 降档/升级:从 C++23 降到这里,把 `std::print` 改成 `std::format` + `std::cout`,把 `std::expected` 改成 `std::optional` 或项目结果类型,去掉 `if consteval`。升级到 C++23 后仍要逐项确认库实现,不要因为 `-std=c++23` 通过就假定 `print`/`stacktrace` 可用。
|
|
35
|
+
- 验证:`compile_commands.json` 的最后一个 `-std=` 必须是 `-std=c++20`;模板在 C++20 下走 `std::format` 分支。
|
|
36
|
+
- 片段:[cmake-snippet.cmake](c++20/cmake-snippet.cmake)。
|
|
37
|
+
|
|
38
|
+
## C++23
|
|
39
|
+
|
|
40
|
+
- 能用:C++20 的全部内容;`std::print`/`std::println`、`std::expected`、`std::stacktrace`、`if consteval`、显式对象参数(deducing this)、`std::mdspan`、`std::flat_map`、ranges 的 C++23 增补(工具链实现为准)。
|
|
41
|
+
- 不能假设:C++23 在 GCC/Clang 上仍是 Partial,具体设施要查编译器状态页;`std::print` 的库门槛是 libstdc++ 14+ / libc++ 19+;`std::stacktrace` 还要链接对应库;`std::expected` 的 monadic 接口、`std::flat_map` 等设施在旧标准库上可能缺失;模板只用 `std::format`,不因为默认 C++23 就强依赖 `print`/`stacktrace`。
|
|
42
|
+
- 降档/升级:从 C++23 降到 C++20 见上一节;升级到 C++26 前先确认 CMake 3.25+、编译器/标准库支持、clang-format 的 `c++26` 枚举,并按 [index.md](index.md#新增标准) 的流程新增片段与矩阵行。
|
|
43
|
+
- 验证:`compile_commands.json` 的最后一个 `-std=` 必须是 `-std=c++23`;模板在 C++23 下走 `std::format` 分支;若使用 `print`/`stacktrace`,另做链接测试。
|
|
44
|
+
- 片段:[cmake-snippet.cmake](c++23/cmake-snippet.cmake)。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:CMake;预算:一次只开这一份(227 行),不自动串联。 -->
|
|
1
2
|
# CMake
|
|
2
3
|
|
|
3
4
|
目标:一个编译器、Ninja、target-based 规则、可用的编译数据库。下面是最小形状和常见边界;工程模板仍由 `building-cpp` 提供,在 `../../../../building-cpp/assets/templates/projects/`,可复用的 CMake 函数在本技能的 `assets/`:`CompileSettings.cmake` 收标准与警告,`LinkSettings.cmake` 收构建期 RPATH 与 GoogleTest 依赖。
|
|
@@ -61,19 +62,19 @@ CompileSettings_SetWarnings(greeting PRIVATE LEVEL standard)
|
|
|
61
62
|
|
|
62
63
|
- 库的 `PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include` 让程序与链接它的测试写 `#include "greeting.h"` 就能找到公共头,不需要各自再写 include 路径。
|
|
63
64
|
- 标准用 `CompileSettings_SetCxxStandard`:库用 `PUBLIC` 传播“至少 C++NN”,程序用 `PRIVATE`;`CXX_STANDARD`/`CXX_EXTENSIONS` 不传播,每个会编译的 target 都要自己调用一次。
|
|
64
|
-
- `CXX_STANDARD_REQUIRED ON` 防止 CMake
|
|
65
|
+
- `CXX_STANDARD_REQUIRED ON` 防止 CMake 在编译器不支持时静默降级;`CXX_EXTENSIONS OFF` 把 `-std=gnu++NN` 收成 `-std=c++NN`。configure 后检查 `compile_commands.json` 的最后一条 `-std=`。
|
|
65
66
|
- 程序 target 固定 `app`;库 target 用组件名。
|
|
66
67
|
|
|
67
68
|
## 标准与复用
|
|
68
69
|
|
|
69
|
-
C++11–C++23 的两层声明、可见性、常见错误与验证见 `../standards/cxx-standard.md`。通用函数 `CompileSettings_SetCxxStandard(target visibility c++NN)` 在 `../assets/CompileSettings.cmake`:
|
|
70
|
+
C++11–C++23 的两层声明、可见性、常见错误与验证见 `../standards/01-cxx-standard.md`。通用函数 `CompileSettings_SetCxxStandard(target visibility c++NN)` 在 `../assets/CompileSettings.cmake`:
|
|
70
71
|
|
|
71
72
|
```cmake
|
|
72
73
|
CompileSettings_SetCxxStandard(app PRIVATE c++23)
|
|
73
74
|
CompileSettings_SetCxxStandard(greeting PUBLIC c++20)
|
|
74
75
|
```
|
|
75
76
|
|
|
76
|
-
函数名不绑定单一标准;新增档位只改函数里的支持列表。模块何时抽、文件怎么放、怎么导入与测试见 `../modules/functions.md`。
|
|
77
|
+
函数名不绑定单一标准;新增档位只改函数里的支持列表。模块何时抽、文件怎么放、怎么导入与测试见 `../modules/01-functions.md`。
|
|
77
78
|
|
|
78
79
|
## 警告等级
|
|
79
80
|
|
|
@@ -90,11 +91,11 @@ MSVC 分支用 `/W4`、`/permissive-`、`/WX`;其他编译器直接报错,
|
|
|
90
91
|
- 每个 target 自己声明 include、标准、编译选项、链接库;不要用全局 `include_directories()`、`add_definitions()`、`CMAKE_CXX_FLAGS` 给所有 target 加料。
|
|
91
92
|
- `target_include_directories(<target> PUBLIC|PRIVATE <dir>)`:公共头给 `PUBLIC`,私有实现目录给 `PRIVATE`。
|
|
92
93
|
- `target_compile_features(<target> PUBLIC|PRIVATE cxx_std_NN)`:只传播“至少 C++NN”的最低要求;精确 `-std` 由 `CompileSettings_SetCxxStandard` 在会编译的 target 上设置,不靠这一步锁死。
|
|
93
|
-
- `target_link_libraries(<target> PRIVATE|PUBLIC <lib>)`:实现依赖用 `PRIVATE`,接口依赖用 `PUBLIC`。
|
|
94
|
+
- `target_link_libraries(<target> PRIVATE|PUBLIC <lib>)`:实现依赖用 `PRIVATE`,接口依赖用 `PUBLIC`。CMake 只硬性要求第一个参数已创建;被链接的库可以稍后定义,CMake 会补 ordering dependency。工程约定仍是先定义后引用,避免靠隐式排序。
|
|
94
95
|
- 不要 `file(GLOB ...)`;显式列源文件,新增文件时改 CMake,构建系统才知道。`CONFIGURE_DEPENDS` 依赖构建系统每次检查目录,跨生成器行为也不完全一致,不作为工程规则。
|
|
95
96
|
- 不把 `main()` 编进库;程序只做装配和 I/O。
|
|
96
97
|
- 头文件不参与编译时,不需要 `target_sources` 列出;需要 IDE 展示时再列。
|
|
97
|
-
- 组件多起来时,一个组件一个 `CMakeLists.txt`:库放 `<component>/include` 与 `<component>/src`,程序放 `
|
|
98
|
+
- 组件多起来时,一个组件一个 `CMakeLists.txt`:库放 `<component>/include` 与 `<component>/src`,程序放 `app/include` 与 `app/src`;`app/include` 只给程序内部用,不要被库 `PUBLIC` 导出。
|
|
98
99
|
- 测试 target 等出现第二个消费者时再加,不要为单个 `main()` 提前引入测试框架;测试只链接库的公共接口。
|
|
99
100
|
|
|
100
101
|
## 工程名
|
|
@@ -191,6 +192,34 @@ LinkSettings_FetchGoogleTest()
|
|
|
191
192
|
- 在 `CMakeLists.txt` 里 `execute_process` 下载依赖或改源码。
|
|
192
193
|
- 用 `CMAKE_CXX_FLAGS` 加 `-std=c++23` 之类与声明不符的标准。
|
|
193
194
|
|
|
195
|
+
## 正反例
|
|
196
|
+
|
|
197
|
+
### CMake 函数注释
|
|
198
|
+
|
|
199
|
+
**差**:
|
|
200
|
+
|
|
201
|
+
```cmake
|
|
202
|
+
#[[.rst:
|
|
203
|
+
CompileSettings_SetWarnings
|
|
204
|
+
---------------------------
|
|
205
|
+
]]
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
`#[[.rst:` 与 `.. command::` 只给要进 CMake 手册的模块用;`@param`、`@return` 是 C++ 的 Doxygen 标签,CMake 里不用;CMake 函数没有返回值,也不写 `:return:`。
|
|
209
|
+
|
|
210
|
+
**好**:
|
|
211
|
+
|
|
212
|
+
```cmake
|
|
213
|
+
# 给一个目标加上编译警告。
|
|
214
|
+
#
|
|
215
|
+
# 只改传入的目标。PRIVATE 不向使用方传播。
|
|
216
|
+
#
|
|
217
|
+
# :param target: 已经存在的 CMake 目标。
|
|
218
|
+
# :param visibility: 取 PRIVATE 或 INTERFACE。
|
|
219
|
+
# :keyword LEVEL: 可省略。取 basic、standard 或 strict;省略时按 standard。
|
|
220
|
+
function(CompileSettings_SetWarnings target visibility)
|
|
221
|
+
```
|
|
222
|
+
|
|
194
223
|
## 依据
|
|
195
224
|
|
|
196
225
|
- [CMake: `add_library`](https://cmake.org/cmake/help/latest/command/add_library.html):库 target 的类型与作用域。
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
<!-- 读取时机:配 CMake 或工具链时;读完能回答:测试与 CTest;预算:一次只开这一份(61 行),不自动串联。 -->
|
|
1
2
|
# 测试与 CTest
|
|
2
3
|
|
|
3
|
-
测试属于构建域:测试 target 由 `engineering` 写进 CMake
|
|
4
|
+
测试属于构建域:测试 target 由 `engineering` 写进 CMake;测试代码的写法由本文件说明,CTest 运行归 `building-cpp` 的通过检查。条文依据 GoogleTest Primer、CMake 的 `add_test` / `gtest_discover_tests` 文档与 CTest 手册,访问日期 2026-10-27。
|
|
4
5
|
|
|
5
6
|
## 先决定测什么
|
|
6
7
|
|
|
@@ -30,7 +31,7 @@ gtest_discover_tests(my_project_test
|
|
|
30
31
|
- 需要独占端口、固定文件或数据库的用例用 `RESOURCE_LOCK`;有准备/清理步骤时用 `FIXTURES_SETUP` / `FIXTURES_REQUIRED`。
|
|
31
32
|
- `--no-tests=error` 防止「0 个测试也算通过」;`--output-on-failure` 只在失败时打印输出,避免日志淹没。
|
|
32
33
|
|
|
33
|
-
##
|
|
34
|
+
## 运行顺序(building-cpp 执行)
|
|
34
35
|
|
|
35
36
|
1. 构建通过后跑 `ctest --test-dir build/<compiler> --output-on-failure --no-tests=error`。
|
|
36
37
|
2. 先跑失败用例的单条:`ctest -R <用例名> --output-on-failure`,确认失败可复现。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:排版或工具配置时;读完能回答:编码与行尾;预算:一次只开这一份(49 行),不自动串联。 -->
|
|
1
2
|
# 编码与行尾
|
|
2
3
|
|
|
3
4
|
默认组合是 UTF-8 无 BOM、LF。机器规则以仓库根 `.gitattributes` 与 `.editorconfig` 为准,本文件只记决定、MSVC 例外与检查方法。
|
|
@@ -32,7 +33,7 @@ MSVC 默认按 BOM 判断源码编码。源码没有 BOM 时,它按当前用
|
|
|
32
33
|
在仓库根运行:
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
|
-
node "<skill-dir>/
|
|
36
|
+
node "<skill-dir>/scripts/checking-encoding.mjs" --profile portable
|
|
36
37
|
```
|
|
37
38
|
|
|
38
39
|
- `portable`(默认)要求所有文本文件 UTF-8 无 BOM、LF、末尾换行。
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
<!-- 读取时机:排版或工具配置时;读完能回答:clang-format;预算:一次只开这一份(20 行),不自动串联。 -->
|
|
1
2
|
# clang-format
|
|
2
3
|
|
|
3
4
|
三件语言工具各管一段:`clang-format` 排版、`clang-tidy` 诊断、`clangd` 提供补全/跳转/诊断。它们都读同一份编译数据库,但职责不重叠。编辑器侧只保留 CMake Tools 作为配置、构建、运行和调试入口;C/C++ 扩展只做 `CMake: Debug` 的调试后端,不参与语言服务。
|
|
4
5
|
|
|
5
6
|
```bash
|
|
6
|
-
clang-format --dry-run --Werror src/*.cpp include/*.h tests/*.cpp
|
|
7
|
+
clang-format --dry-run --Werror src/*.cpp include/*.h app/*.cpp tests/*.cpp
|
|
7
8
|
```
|
|
8
9
|
|
|
9
10
|
- 检查用 `--dry-run --Werror`;需要自动修复时单独跑 `clang-format -i`,不要在构建脚本里悄悄改源码。
|
|
10
11
|
- 工程必须有根 `.clang-format`;缺失时先复制配置,不要回退到内置风格,回退会掩盖配置缺失。
|
|
11
|
-
- 只扫描项目源码:`src/`、`include/`、`
|
|
12
|
+
- 只扫描项目源码:`src/`、`include/`、`app/`、`tests/` 等实际存在的目录;不扫描 `build/`、第三方、生成文件。
|
|
12
13
|
- 配置文件在工程根 `.clang-format`;不要依赖用户主目录或编辑器内置配置。
|
|
13
14
|
- `BasedOnStyle: Google`、`Standard: Latest`;`c++23` 到 clang-format 23 才被接受,21 与 22 会报 `error: unknown enumerated scalar`,`Latest` 在旧版本上按该版本支持的最高标准解析。列宽、缩进与包含顺序以工程根 `.clang-format` 为准;工程显式写 `ColumnLimit` 时按工程值执行,模板资产不写 `ColumnLimit`。
|
|
14
15
|
- 格式化失败就是失败,不要用 `// clang-format off` 绕过;确需关闭时只包住无法排版的宏或表格,并写一句理由。
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
+
<!-- 读取时机:排版或工具配置时;读完能回答:clang-tidy 与静态检查门禁;预算:一次只开这一份(58 行),不自动串联。 -->
|
|
1
2
|
# clang-tidy 与静态检查门禁
|
|
2
3
|
|
|
3
4
|
## clang-tidy
|
|
4
5
|
|
|
5
6
|
```bash
|
|
6
7
|
clang-tidy -p build/clang \
|
|
7
|
-
--header-filter="^$(pwd -P)/(include|src|
|
|
8
|
+
--header-filter="^$(pwd -P)/(include|src|app|tests)/" \
|
|
8
9
|
--warnings-as-errors='*' \
|
|
9
|
-
src/*.cpp
|
|
10
|
+
src/*.cpp app/*.cpp tests/*.cpp
|
|
10
11
|
```
|
|
11
12
|
|
|
12
13
|
- `-p` 指向当前编译器的构建目录,读取 `compile_commands.json`。
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:排版或工具配置时;读完能回答:clangd 与编辑器;预算:一次只开这一份(91 行),不自动串联。 -->
|
|
1
2
|
# clangd 与编辑器
|
|
2
3
|
|
|
3
4
|
## clangd
|
|
@@ -63,6 +64,7 @@ Diagnostics:
|
|
|
63
64
|
],
|
|
64
65
|
"cmake.buildDirectory": "${workspaceFolder}/build/clang",
|
|
65
66
|
"cmake.generator": "Ninja",
|
|
67
|
+
"cmake.configureOnOpen": true,
|
|
66
68
|
"cmake.buildBeforeRun": true,
|
|
67
69
|
"cmake.exportCompileCommandsFile": true,
|
|
68
70
|
"cmake.debugConfig": {
|
package/skills/engineering/references/formatting/examples/{clang-format.md → 01-clang-format.md}
RENAMED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
<!-- 读取时机:排版或工具配置时;读完能回答:正反例:clang-format;预算:一次只开这一份(38 行),不自动串联。 -->
|
|
1
2
|
# 正反例:clang-format
|
|
2
3
|
|
|
3
4
|
## 构建脚本里自动格式化
|
|
@@ -35,4 +36,4 @@ BasedOnStyle: Google
|
|
|
35
36
|
Standard: Latest
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
配置只选预设和语言版本,不重复策略;列宽、缩进、包含顺序都由 Google
|
|
39
|
+
配置只选预设和语言版本,不重复策略;列宽、缩进、包含顺序都由 Google 预设决定。需要新规则时先改技能文档并说明理由,不要在手写配置里堆本地约定。两例的差别在把策略写进配置头,不是 `ColumnLimit`;要改列宽时按工程值设置并改技能依据。
|