• 6616阅读
  • 2回复

[提问]Q_FUNC_INFO的实现 [复制链接]

上一主题 下一主题
离线aesoplord
 

只看楼主 倒序阅读 楼主  发表于: 2012-09-25
请问各位有没有研究过Q_FUNC_INFO怎么用标准C++实现,因为我觉得这个打印的信息还是挺全的,希望也能在非Qt的C++代码上实现。求达人帮忙,谢谢。
离线aesoplord

只看该作者 1楼 发表于: 2012-09-25
自己也跟踪了一下,但是没看出来什么眉目。
#if (defined(Q_CC_GNU) && !defined(Q_OS_SOLARIS)) || defined(Q_CC_HPACC) || defined(Q_CC_DIAB)
#  define Q_FUNC_INFO __PRETTY_FUNCTION__
#elif defined(_MSC_VER)
#  define Q_FUNC_INFO __FUNCSIG__
#else
#   if defined(Q_OS_SOLARIS) || defined(Q_CC_XLC) || defined(Q_OS_SYMBIAN) || defined(Q_OS_INTEGRITY)
#      define Q_FUNC_INFO __FILE__ "(line number unavailable)"
#   else
        /* These two macros makes it possible to turn the builtin line expander into a
         * string literal. */
#       define QT_STRINGIFY2(x) #x
#       define QT_STRINGIFY(x) QT_STRINGIFY2(x)
#       define Q_FUNC_INFO __FILE__ ":" QT_STRINGIFY(__LINE__)
#   endif
    /* The MIPSpro and RVCT compilers postpones macro expansion,
       and therefore macros must be in scope when being used. */
#   if !defined(Q_CC_MIPS) && !defined(Q_CC_RVCT) && !defined(Q_CC_NOKIAX86)
#       undef QT_STRINGIFY2
#       undef QT_STRINGIFY
#   endif
#endif
离线aesoplord

只看该作者 2楼 发表于: 2012-10-10
自己试验了一下,研究明白了。
快速回复
限100 字节
 
上一个 下一个