Here is the code.
#include <iostream>
using namespace std;
#define gao falsegao
#define fun(entity) \
void fun_##entity() \
{ \
std::cout << #entity << std::endl; \
}
fun(gao);
int main()
{
fun_gao();
return 0;
}
This program will compile and run at ease. But why? I have already defined gao
as falsegao
, shouldn't the generated function be void fun_false_gao()
? And the output should be false_gao
, too.
Please help me solve this puzzle, when will the substitution take place ? what's the principle behind this?