GCC 预定义了两个标识符来保存当前函数的名称。 标识符 __FUNCTION__ 包含函数在源代码中出现的名称。 标识符 __PRETTY_FUNCTION__ 包含以特定语言方式漂亮打印的函数名称。
https://www.onlinegdb.com/ online gdb 验证
这些名称在 C 函数中始终相同,但在 C++ 函数中它们可能不同。 例如,这个程序:
#includevoid test_macroFunction(int i, int j) { printf("%d %dn", i,j); printf ("__FUNCTION__ = %sn", __FUNCTION__); printf ("__PRETTY_FUNCTION__ = %sn", __PRETTY_FUNCTION__); }; int main (void) { test_macroFunction(100,200); return 0; }
C编译器打印输出:
100 200 __FUNCTION__ = test_macroFunction __PRETTY_FUNCTION__ = test_macroFunction
C++ 编译器打印输出:
100 200 __FUNCTION__ = test_macroFunction __PRETTY_FUNCTION__ = void test_macroFunction(int, int)



