今天看到一个问题关于##的,特意记录一下
出现在宏定义之中的##,用来告诉编译器,把两个字符串系在一起
参考例子: // glue.c -- use the ## operator #include <stdio.h> #define XNAME(n) x ## n #define PRINT_XN(n) printf("x" #n " = %d/n", x ## n); int main(void) { int XNAME(1) = 14; // becomes int x1 = 14; int XNAME(2) = 20; // becomes int x2 = 20; PRINT_XN(1); // becomes printf("x1 = %d/n", x1); PRINT_XN(2); // becomes printf("x2 = %d/n", x2); return 0; } Here's the output: x1 = 14 x2 = 20
|