1. ‘#’用于将目标扩展成字符串,如:
#define to_str(a) #a
如果这样使用:
const char foo[] = to_str(hello world);
宏扩展后会是:
const char foo[] = "hello world";
本质上就是对#后面的目标加上双引号。
2. ‘##’ 用于将两个目标进行连接, 如:
#define a_and_b(a, b) a##_##b
如果这样使用:
void a_and_b(Win32, Init)(void)
{
//...
}
宏扩展后会是:
void Win32_Init(void)
{
//...
}