小编non*_*ipt的帖子

动态变量名称:用文本连接宏定义

是否可以使用常规文本加入宏定义?

例如;

#define T_NAME      Text_Int       
#define MAP_KEYS    T_NAME _Map_Keys      // defined in a separate header file "a.h"

// I am hoping MAP_KEYS = Text_Int_Map_Keys
Run Code Online (Sandbox Code Playgroud)

所以我可以去:

#undef T_NAME
#undef MAP_KEYS
#define T_NAME      Text_Real       
#define MAP_KEYS    T_NAME _Map_Keys

#undef T_NAME
#undef MAP_KEYS
#define T_NAME      Text_Short       
#define MAP_KEYS    T_NAME _Map_Keys
Run Code Online (Sandbox Code Playgroud)

c c-preprocessor

2
推荐指数
1
解决办法
2103
查看次数

标签 统计

c ×1

c-preprocessor ×1