如何在调试字符串的函数中获取函数名称? [英] How to get the function name while in a function for debug strings?

查看:178
本文介绍了如何在调试字符串的函数中获取函数名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在每次调用时输出函数名,我可以轻松地复制和粘贴函数名,但是我想知道是否有一个快捷方式可以为我做这个工作?



目前我在做:

  SlideInfoHeader * lynxThreeFile :: readSlideInfoHeader(QDataStream& in) 
{
qDebug(lynxThreeFile :: readSlideInfoHeader);
}

但我想要的是一般的:



SlideInfoHeader * lynxThreeFile :: readSlideInfoHeader(QDataStream& in)
{
qDebug(this.className()+:: this.functionName());
}


解决方案

__ FUNCTION __ 由MSVC和GCC支持,并应为您提供所需的信息。


I want to output the function name each time it is called, I can easily copy and paste the function name, however I wondered if there was a shortcut that would do the job for me?

At the moment I am doing:

SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream & in)
{
    qDebug("lynxThreeFile::readSlideInfoHeader");
}

but what I want is something generic:

SlideInfoHeader* lynxThreeFile::readSlideInfoHeader(QDataStream & in)
{
    qDebug(this.className() + "::" + this.functionName());
}

解决方案

"__FUNCTION__" is supported by both MSVC and GCC and should give you the information you need.

这篇关于如何在调试字符串的函数中获取函数名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆