文章目录
参考gcc
func
FUNCTION
PRETTY_FUNCTION
如果试C++
使用这些宏定义,是mangle之前的函数名称。
6.48 Function Names as Strings
GCC provides three magic constants that hold the name of the current function as a string.
In C++11 and later modes, all three are treated as constant expressions and can be used
in constexpr constexts. The first of these constants is func, which is part of the C99
standard:
The identifier func is implicitly declared by the translator as if, immediately following
the opening brace of each function definition, the declaration
static const char func[] = “function-name”;
appeared, where function-name is the name of the lexically-enclosing function. This name
is the unadorned name of the function. As an extension, at file (or, in C++, namespace
scope), func evaluates to the empty string.
FUNCTION is another name for func, provided for backward compatibility with
old versions of GCC.
In C, PRETTY_FUNCTION is yet another name for func, except that at file (or,
in C++, namespace scope), it evaluates to the string “top level”. In addition,