微距/关键字,可用于打印方法的名字吗? [英] Macro / keyword which can be used to print out method name?
本文介绍了微距/关键字,可用于打印方法的名字吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
__ __ FILE
和 __ __ LINE
是众所周知的。有一个 __ __ FUNC
自C99。
__FILE__
and __LINE__
are well known. There is a __func__
since C99.
#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
有没有宏观/关键字,它会输出方法名称,如富::待办事项
?
推荐答案
升压有一个名为特殊工具宏<一个href=\"http://www.boost.org/doc/libs/1_42_0/libs/utility/current_function.html\">BOOST_CURRENT_FUNCTION隐藏编译器实现之间的差异。
Boost has a special utility macro called BOOST_CURRENT_FUNCTION that hides the differences between the compiler implementations.
随着它的实现,我们看到有依赖于编译器的几个宏:
Following it's implementation we see that there are several macros depending on compiler:
-
__ preTTY_FUNCTION __
- GCC,Metrowerks公司,数字火星,国际商会,MinGW的 -
__ __ FUNCSIG
- MSVC -
__ __功能
- 英特尔和IBM -
__ __ FUNC
- Borland公司 -
__ __ FUNC
- ANSI C99
__PRETTY_FUNCTION__
-- GCC, MetroWerks, Digital Mars, ICC, MinGW__FUNCSIG__
-- MSVC__FUNCTION__
-- Intel and IBM__FUNC__
-- Borland__func__
-- ANSI C99
这篇关于微距/关键字,可用于打印方法的名字吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文