链接:http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html#Function-Names

GCC provides three magic variables that hold the name of the current function, as a string. The first of these 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. __FUNCTION__ is another name for __func__. Older versions of GCC recognize only this name. However, it is not standardized. For maximum portability, we recommend you use __func__, but provide a fallback definition with the preprocessor: #if __STDC_VERSION__ < 199901L
# if __GNUC__ >=
# define __func__ __FUNCTION__
# else
# define __func__ "<unknown>"
# endif
#endif
In C, __PRETTY_FUNCTION__ is yet another name for __func__. However, in C++, __PRETTY_FUNCTION__ contains the type signature of the function as well as its bare name. For example, this program: extern "C" {
extern int printf (char *, ...);
} class a {
public:
void sub (int i)
{
printf ("__FUNCTION__ = %s\n", __FUNCTION__);
printf ("__PRETTY_FUNCTION__ = %s\n", __PRETTY_FUNCTION__);
}
}; int
main (void)
{
a ax;
ax.sub ();
return ;
}
gives this output: __FUNCTION__ = sub
__PRETTY_FUNCTION__ = void a::sub(int)
These identifiers are not preprocessor macros. In GCC 3.3 and earlier, in C only, __FUNCTION__ and __PRETTY_FUNCTION__ were treated as string literals; they could be used to initialize char arrays, and they could be concatenated with other string literals. GCC 3.4 and later treat them as variables, like __func__. In C++, __FUNCTION__ and __PRETTY_FUNCTION__ have always been variables.

GNU :6.47 Function Names as Strings的更多相关文章

  1. Function Names as Strings

    [Function Names as Strings] GCC provides three magic variables that hold the name of the current fun ...

  2. REST Representational state transfer REST Resource Naming Guide Never use CRUD function names in URIs

    怎样用通俗的语言解释什么叫 REST,以及什么是 RESTful? - 知乎  https://www.zhihu.com/question/28557115 大家都知道"古代"网 ...

  3. C++库研究笔记——函数名的宏定义

    6.47 Function Names as Strings:http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html GCC provides th ...

  4. 在golang中使用 cgo,如何让被嵌入的c语言代码调用golang

    https://golang.org/misc/cgo/test/callback.go // Copyright 2011 The Go Authors. All rights reserved. ...

  5. 高性能python

    参考来源:Python金融大数据分析第八章 提高性能有如下方法 1.Cython,用于合并python和c语言静态编译泛型 2.IPython.parallel,用于在本地或者集群上并行执行代码 3. ...

  6. Consuming JSON Strings in SQL Server

    https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/ Consuming JS ...

  7. clean code meaningful names

    ---恢复内容开始--- Meaningful Names: use Intention-Revealing Names //nice,Everyone who reads your code (in ...

  8. Working with Strings(使用Oracle字符串)

    Working with Strings By Steven Feuerstein  Part 3 in a series of articles on understanding and using ...

  9. Named function expressions demystified

    Introduction Surprisingly, a topic of named function expressions doesn't seem to be covered well eno ...

随机推荐

  1. 方法:Linux 下用JAVA获取CPU、内存、磁盘的系统资源信息

    CPU使用率: InputStream is = null; InputStreamReader isr = null; BufferedReader brStat = null; StringTok ...

  2. linux开机启动增加tomcat启动项

    需求:开发环境(linux)重启后,每次需手动启动相关应用较为繁琐,如设置为开机自动启动则可减少此工作量. google下,参考了以下博文较好解决了问题: 1. 简单说明 Centos下设置程序开机自 ...

  3. DCL_数据库控制语言

    DCL(Data Control Language)              -------是数据库控制语言.是用来设置或更改数据库用户或角色权限的语句,包括(grant,deny,revoke等) ...

  4. JS焦点图,JS 多个页面放多个焦点图

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. [DevExpress]GridControl 列头绘制Checkbox

    关键代码: /// <summary> /// 为列头绘制CheckBox /// </summary> /// <param name="view" ...

  6. js判断屏幕分辨率的代码

    通过下面的代码判断分辨率 <script language="JavaScript"> <!-- Begin function redirectPage() { ...

  7. A3992学习记录

    ATmega64+A3992驱动步进电机 //ATmega 64a 电机驱动板程序//编译环境 AVR Studio 4.17/AVR GCC//系统外部时钟16M//作者:虞恺 //日期:2012. ...

  8. zhuan:ubuntu下安装Apache2+php+Mysql

    from: http://www.cnblogs.com/lynch_world/archive/2012/01/06/2314717.html ubuntu下安装Apache+PHP+Mysql 转 ...

  9. 浅谈string

    #include <string>// 注意是<string>,不是<string.h>,带.h的是C语言中的头文件 using std::string;using ...

  10. 在Qt Creator中添加OpenCV库

    在项目的pro文件中添加如下代码:INCLUDEPATH += D:/opencv/build/include win32:CONFIG(debug, debug|release): {LIBS += ...