链接: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. Item47

    STL迭代器分类:input迭代器.output迭代器.forward迭代器.bidirectional迭代器.random access迭代器. Input迭代器:只能向前移动,一次一步,客户只读取 ...

  2. 函数 sort,unique,stable_sort,count_if,谓词

    bool isShorter(const string &s1,const string &s2) { return s1.size() < s2.size(); } bool ...

  3. Nginx日志按天分割

    核心思想:使用crontab在每日23:59执行日志分割. 1.配置nginx日志信息,vim /etc/logrotate.d/nginx /var/log/nginx/*.log { nocomp ...

  4. 上传图片(基于zepto.js)

    效果如下: <div class="otherPic"> <div id="showOtherImage"></div> & ...

  5. [原创] linux课堂-学习笔记-课程3.Linux目录结构介绍及内核与shell分析

    一.目录说明 1.1 bin 一般用户,可执行的系统内置命令 1.2 sbin 系统管理员,可执行的系统内置命令 1.3 boot 启动文件目录,启动有关的文件都保存在此 1.4 dev 设备管理文件 ...

  6. Android Google购买PHP服务器端验证(订阅购买和一次性购买)

    一.订阅购买验证 android端采用google service account进行校验 1.打开https://cloud.google.com/console创建一个project: 2.打开p ...

  7. phpstorm配置取消掉63342

    http://ask.csdn.net/questions/171665

  8. delphi中的临界区

    var fLock:TRTLCriticalSection; //定义临界区域 // 初始化 InitializeCriticalSection(fLock); //进入临界区 EnterCritic ...

  9. ISO-9126 软件质量模型

    摘要 在软件开发过程中,软件的质量是一个重要的因素,而软件体系结构在整个过程中显得尤为重要.软件的质量需求是在开发初期的非功能性需求,对软件的体系结构影响很大.但是并不意味着一味的追求质量,必须在效率 ...

  10. python 模拟ajax查询社工库...

    在windows中使用,输入有关信息查询社工库,本来是网页版的,我把ajax请求提取出来.粗略的封装下,挺好玩. #coding:utf8 import urllib2,urllib from Bea ...