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__;
}