是否有可能在C ++中获得当前的(成员)函数名称? [英] Is it ever possible to get the current (member) function name in C++?
本文介绍了是否有可能在C ++中获得当前的(成员)函数名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对RTTI不太了解,但是我相信,有了它,您可以在运行时检索变量的名称。
是否可以检索线程当前正在运行的函数的名称?
解决方案
C ++ 11为当前函数标准化了 __ func __
。 / p>
各种编译器支持 __ FUNCTION __
, __ PRETTY_FUNCTION __
和其他人。
I don’t know much about RTTI, but I believe that thanks to that you can retrieve the name of variables at run-time. Is it possible to retrieve the name of the function the thread is currently running ?
解决方案
C++11 standardized __func__
for the current function.
Various compilers support variations of __FUNCTION__
, __PRETTY_FUNCTION__
, and others.
这篇关于是否有可能在C ++中获得当前的(成员)函数名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文