有这样一个宏
#define DEFINE_SUPERNAME(name)/
struct super_##name {/
static const char *getname() {/
return #name;/
}/
}
具体含义是
# 是宏处理的字符串转换符
#define STRING(exp) #exp
那么 STRING(okokokok) 就相当于 "okokokok"
## 是宏处理的标识符拼接符
#define FULL_IDENT(ident) sys_global_##ident
那么 FULL_IDENT(cache) 就等于 sys_global_cache
综上 DEFINE_SUPERNAME(suhugo) 相当于
struct super_suhugo{
static const char *getname() {
return "suhugo";
}
}