__FILE__
和__LINE__
是众所周知的。自C99以来有一个__func__
。可用于打印方法名称的宏/关键字?
#include <iostream>
struct Foo {
void Do(){ std::cout << __func__ << std::endl; }
};
int main()
{
std::cout << __func__ << std::endl;
Foo foo; foo.Do();
return 0;
}
将输出
main
Do
是否有宏/关键字像Foo::Do
那会输出方法的名字吗?
无法决定最佳答案。我点了点东西,然后向其他人道歉:-)。 – Notinlist 2010-02-03 14:58:16
相关:http://stackoverflow.com/questions/4384765/whats-the-difference-between-pretty-function-function-func – 2016-02-18 12:56:17