今天在翻看别人用C语言写的框架代码的时候注意到了大量的使用宏拼接,以此进行C风格的模板设计。一直没有想到原来C的宏可以这么使用,记录下来涨点见识!
#include <stdio.h>
#define concat(x, y) x ## y
int main()
{
printf("%d\n", concat(1, 2));
return 0;
}
今天在翻看别人用C语言写的框架代码的时候注意到了大量的使用宏拼接,以此进行C风格的模板设计。一直没有想到原来C的宏可以这么使用,记录下来涨点见识!
#include <stdio.h>
#define concat(x, y) x ## y
int main()
{
printf("%d\n", concat(1, 2));
return 0;
}