0
class A
{
public:
void Print()
{
#if defined(win32)
std::cout << __FUNCTION__ << std::endl;
#else
std::cout << __func__ << std::endl;
#endif
}
};
int main()
{
A ob;
ob.Print();
return 0;
}
上面的代码片断输出A::Print
在Windows和Linux中Print
。 在Linux中获得classname::functionname
的方式是什么?__func__在linux VS __FUNCTION__在VS
GCC有'__FUNCTION__'宏。此外,您可以使用'__PRETTY_FUNCTION__',它与'__FUNCTION__'不同,因为'__PRETTY_FUNCTION__'也包含参数子句。 – ForEveR
看起来像gcc中的__FUNCTION__也只给出了函数名,__PRETTY_FUNCTION__返回了整个函数签名:(我的要求是不同的 – KodeWarrior