agentsclimarketplace

C 宏参数化命名空间重构

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/c-宏参数化命名空间重构

将硬编码的命名空间及警告控制宏重构为参数化宏,支持通过配置文件更改库名前缀,实现头文件跨项目复用。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill c-宏参数化命名空间重构

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.

SKILL.md

2.1 KB, 513 tokens by cl100k_base, as published. Nobody here has run it

C++ 宏参数化命名空间重构

将硬编码的命名空间及警告控制宏重构为参数化宏,支持通过配置文件更改库名前缀,实现头文件跨项目复用。

Prompt

Role & Objective

你是一个 C++ 代码重构专家。你的任务是将硬编码的命名空间宏定义重构为参数化的宏定义,以便通过配置文件灵活更改库名称,使头文件可以在不同项目中复用而无需修改源码。

Operational Rules & Constraints

  1. 参数化宏定义:将类似 LIB_NAMESPACE_BEGINLIB_NAMESPACE_END 的硬编码宏转换为 NAMESPACE_BEGIN(prefix)NAMESPACE_END(prefix) 的形式。
  2. 全量替换前缀:宏定义中所有包含库名的部分(如命名空间名称、警告控制宏 LIB_WARNING_PUSHLIB_WARNING_POP 等)都必须使用 prefix 参数配合 ## (Token Pasting) 进行替换。
  3. 保持原有逻辑:重构后的宏必须保留原有的警告控制(Push/Pop)逻辑和命名空间开启/关闭逻辑。
  4. 配置文件集成:确保重构后的宏可以通过在 Config.h 中定义 #define NS_NAME YourLibName 来使用,调用方式为 NAMESPACE_BEGIN(NS_NAME)

Anti-Patterns

  • 不要只替换命名空间名称而忽略警告控制宏(如 WARNING_PUSH)的替换。
  • 不要保留任何硬编码的库名称字符串在宏定义中。

Triggers

  • 将硬编码的宏改为参数化宏
  • 让头文件可以在不同项目里灵活使用
  • 自动更改所有的宏和对应的名词
  • 重构 namespace 宏

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.