#define f (a, b) a ## b
#define g (a) #a
#define h (a) g (a)
So, ## combine the two parts directly together, no matter what types they are ... Give an example. printf("%d\n",f(1,2)); you get 12, which means that here f (1,2) is 12 integers.
int a2 = 100;
printf ("% d \ n", f (a, 2));
here f (a, 2) is a label. it points to a label in your code context, if there is no int a2 = 100 , you get compilation errors. And #a turns everything that is into a string ... And then h(a) g(a) This is very strange .. It looks like when you call h (a), it goes into g (a) and passes a to g (a), firstly, it interprets what a is. so before you can g (a), a is converted to f (a, b) = a ## b = 12
Shaobo wang
source share