c99标准中的__func__预定义标识符功能可以帮我们获取函数的名称
#include<string>
#include<iostream>
using namespace std;const char *hello(){return __func__;
}int main(){cout<<hello()<<endl;return 0;
}
代码中的函数相当于:
const char *hello(){static const char * __func__="hello";return __func__;
}