#include <iostream> class A{ public: void myfunction(){ std::cout << __func__; } }; int main(){ A obj; obj.myfunction(); }@H_403_4@输出是myfunction.不幸的是__funct__不起作用.如何输出成员函数的完全限定名,即A :: myfunction?
解决方法
没有标准的定义方式.但是,如果您使用的是gcc,则可以使用__PRETTY_FUNCTION__而不是__func__.
@H_403_4@标准C(即C 03)没有__func__或__PRETTY_FUNCTION__.
@H_403_4@C 0x从C99派生__func__,它在8.4.2 / 8(n3290)中定义
@H_403_4@The function-local predefined variable__func__
is defined as if a definition of the form @H_403_4@static const char __func__[] = "function-name ";
@H_403_4@had been provided,where function-name is an implementation-defined string