원클릭으로
mcpp-style-ref
为 mcpp 项目应用 Modern/Module C++ (C++23) 编码风格。适用于编写或审查带模块的 C++ 代码、命名标识符、组织 .cppm/.cpp 文件,或用户提及 mcpp、module C++、现代 C++ 风格时。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
为 mcpp 项目应用 Modern/Module C++ (C++23) 编码风格。适用于编写或审查带模块的 C++ 代码、命名标识符、组织 .cppm/.cpp 文件,或用户提及 mcpp、module C++、现代 C++ 风格时。
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
构建 xlings 项目的三平台操作指南,覆盖 Linux、macOS、Windows 上的工具链准备、`mcpp` 构建、release 脚本和构建后验证。
xlings 项目贡献规范流程 — 从 issue 到 PR 合入的完整 agent 开发工作流。Use when implementing features, fixing bugs, or contributing code to xlings. Covers environment setup, branching, coding, testing, PR creation, and CI verification.
xlings 项目文档编写规范 — 面向人的 docs/ 目录文档应遵循的风格、格式和组织约定。Use when creating or modifying documents in the docs/ directory.
xlings 包管理器完整使用指南 — 安装、多版本管理、SubOS 隔离环境、项目模式、Agent 集成、包索引生态。Use when tasks involve xlings install/use/search/remove flows, subos lifecycle (new/use/fork/stop/remove), project-mode .xlings.json setup, agent sandbox workflows, or custom index/resource-server configuration.
使用 xlings (XLINGS Quickstart) 进行工具安装、版本管理、包索引扩展和 subos 环境隔离的操作指南。When tasks involve `xlings`/`xim` package install-search-update-remove flows, namespace package handling, self-hosted/custom index repo setup, or multi-version/subos troubleshooting, use this skill.
| name | mcpp-style-ref |
| description | 为 mcpp 项目应用 Modern/Module C++ (C++23) 编码风格。适用于编写或审查带模块的 C++ 代码、命名标识符、组织 .cppm/.cpp 文件,或用户提及 mcpp、module C++、现代 C++ 风格时。 |
mcpp 项目的 Modern/Module C++ 风格参考。C++23,使用 import std。
| 种类 | 风格 | 示例 |
|---|---|---|
| 类型/类 | PascalCase(大驼峰) | StyleRef, HttpServer |
| 对象/成员 | camelCase(小驼峰) | fileName, configText |
| 函数 | snake_case(下划线) | load_config_file(), parse_() |
| 私有 | _ 后缀 | fileName_, parse_() |
| 常量 | UPPER_SNAKE | MAX_SIZE, DEFAULT_TIMEOUT |
| 全局 | g 前缀 | gStyleRef |
| 命名空间 | 全小写 | mcpplibs, mylib |
import std 替代 #include <print> 和 #include <xxx>.cppm 作为模块接口;分离实现时用 .cppexport module module_name; — 模块声明export import :partition; — 导出分区import :partition; — 内部分区(不导出)// .cppm
export module a;
export import a.b;
export import :a2; // 可导出分区
import std;
import :a1; // 内部分区
topdir.subdir.filename(如 a.b, a.c)module_name:partition(如 a:a1, a.b:b1)a/c.cppm → a.c,b/c.cppm → b.cclass StyleRef {
private:
std::string fileName_; // 数据成员带 _ 后缀
public: // Big Five
StyleRef() = default;
StyleRef(const StyleRef&) = default;
// ...
public: // 公有接口
void load_config_file(std::string fileName); // 函数 snake_case,参数 camelCase
private:
void parse_(std::string config); // 私有函数以 _ 结尾
};
{} — int n { 42 },std::vector<int> v { 1, 2, 3 }std::string_viewstd::optional / std::expected 替代 int 错误码std::unique_ptr、std::shared_ptr;避免裸 new/deleteconstexpr、inline、concept 替代宏两种写法均支持。
写法 A:合并 — 接口与实现同在一个 .cppm 中:
// mylib.cppm
export module mylib;
export int add(int a, int b) {
return a + b;
}
写法 B:分离 — 接口在 .cppm,实现在 .cpp(编译期隐藏实现):
// error.cppm(接口)
export module error;
export struct Error {
void test();
};
// error.cpp(实现)
module error;
import std;
void Error::test() {
std::println("Hello");
}
简单模块用写法 A;需隐藏实现或减少编译依赖时用写法 B。
安装 xlings 包管理器后,获取 GCC 15 工具链:
curl -fsSL https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.sh | bash
irm https://raw.githubusercontent.com/d2learn/xlings/refs/heads/main/tools/other/quick_install.ps1 | iex
然后安装工具链(仅linux, 其中windows默认用msvc):
xlings install gcc@15 -y
xlings详细信息可参考 xlings 文档。
参考本仓库 src/ 目录结构:
mcpp.toml:声明 C++23 模块目标、工具链和依赖add_files("main.cpp")、add_files("**.cppm") 添加源文件mcpp-style-ref 主程序、error 静态库)构建:
mcpp build
mcpp test
.cppm、.cpp)