70,023
社区成员




3.宏的单行定义(少见用法)
#define A(x) T_##x
#define B(x) #@x
#define C(x) #x
我们假设:x=1,则有:
A(1)------〉T_1
B(1)------〉'1'
C(1)------〉"1"
(这里参考了 hustli的文章)
int a=TRACE(5); // a = (printf("%s;\n", "5"), 5);
#define TRACE(S) (printf("%s;\n", #S), S) /*注意用逗号而不是分号*/
int main()
{
int a=5;
int b=TRACE(a);
const char *str="hello";
char des[50];
strcpy(des,TRACE(str));
puts(des);
system("pause");
return 0;
}