playbook/docs/cpp/naming.md

32 lines
1.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# C++ 命名规范Naming
本章节以 Google C++ Style Guide 为基线并补充模块化Modules相关的命名约定。
## 1. 总原则
- 一致性优先:以仓库现有风格为准,标准用于“无上下文/新代码”的默认选择。
- 名字体现作用域与语义,不用 `tmp/data/info` 这类弱语义词。
## 2. 命名风格总览(默认)
- 类型class/struct/enum/using`PascalCase`
- 函数/方法:`PascalCase`
- 变量:`lower_snake_case`
- 成员变量:`lower_snake_case_`尾随下划线Google
- 常量:`kPascalCase`(编译期/全局固定值)
- 命名空间:`lowercase` 或 `lower_snake_case`(按项目约定,建议全仓统一)
## 3. 文件命名
- 文件名:`lower_snake_case`(与 Google 风格一致)
- 头文件:`foo_bar.h`
- 源文件:`foo_bar.cc`
- Module 文件:`foo_bar.cppm`
## 4. Modules 命名
- Module 名使用点分层级:`<root>.<subsystem>.<component>`
- 每一段建议用 `lower_snake_case`
- 示例:`my_project.market.data_feed`
- 文件路径建议与 module 名可映射(便于检索与定位)。