const char*Q_FUNC_INFO

Expands to a string that describe the function the macro resides in. How this string looks more specifically is compiler dependent. With GNU GCC it is typically the function signature, while with other compilers it might be the line and column number.
Q_FUNC_INFO can be conveniently used with qDebug().

展开为描述宏所在函数的字符串。这个字符串的具体外观取决于编译器。对于 GNU GCC,它通常是函数签名,而对于其他编译器,它可能是行号和列号。Q_FUNC_INFO 可以方便地与 qDebug() 一起使用。

For example, this function:

1
2
3
4
5
6
7
8
9
10
template<typename TInputType>
const TInputType &myMin(const TInputType &value1, const TInputType &value2)
{
qDebug() << Q_FUNC_INFO << "was called with value1:" << value1 << "value2:" << value2;

if(value1 < value2)
return value1;
else
return value2;
}

when instantiated with the integer type, will with the GCC compiler produce:
const TInputType& myMin(const TInputType&, const TInputType&) [with TInputType = int] was called with value1: 3 value2: 4
If this macro is used outside a function, the behavior is undefined.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void QFuncInfo()
{
qDebug(Q_FUNC_INFO);
}

void QFuncInfo(int i)
{
Q_UNUSED(i);
qDebug(Q_FUNC_INFO);
}

/**
输出:
void __cdecl QFuncInfo(int)
void __cdecl QFuncInfo(void)
*/