是否有 GCC __PRETTY_FUNCTION__ 等同于它所提供的文字参数?
Is there a GCC __PRETTY_FUNCTION__ equivelent for literal arguments it was fed?
如果我的函数是:
void foo(bool bar)
{
qDebug() << __PRETTY_FUNCTION__;
}
foo(getBool());
将输出 "void foo(bool bar)"
我想要更多的 strace 结果,这样:
foo(getBool());
将输出 "getBool()"
解决此问题的最佳方法是什么?
一个要求是 foo(boolbar)
将被放入一个动态库中,例如:
#include "Custom Library/output_tools.h"
进入项目。
为什么不为此使用宏?
#define printBoolFunctionAndResult(bar) qDebug() << #bar << " " << bar;
这里使用字符串化运算符将宏参数转换为字符串,并首先直接打印参数,然后对其求值。
这里是 std::cout
的工作示例:https://repl.it/repls/IntelligentGrayGermanpinscher
如果我的函数是:
void foo(bool bar)
{
qDebug() << __PRETTY_FUNCTION__;
}
foo(getBool());
将输出 "void foo(bool bar)"
我想要更多的 strace 结果,这样:
foo(getBool());
将输出 "getBool()"
解决此问题的最佳方法是什么?
一个要求是 foo(boolbar)
将被放入一个动态库中,例如:
#include "Custom Library/output_tools.h"
进入项目。
为什么不为此使用宏?
#define printBoolFunctionAndResult(bar) qDebug() << #bar << " " << bar;
这里使用字符串化运算符将宏参数转换为字符串,并首先直接打印参数,然后对其求值。
这里是 std::cout
的工作示例:https://repl.it/repls/IntelligentGrayGermanpinscher