'#'是把宏参数转化为字符串的运算符,'##'是把两个宏参数连接的运算符。
例如:
#define STR(arg) #arg 则宏STR(hello)展开时为”hello”
#define NAME(y) name_y 则宏NAME(1)展开时仍为name_y
#define NAME(y) name_##y 则宏NAME(1)展开为name_1
#define DECLARE(name, type) typename##_##type##_type,
则宏DECLARE(val, int)展开为int val_int_type
网友评论