GNU :6.47 Function Names as Strings
链接: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的更多相关文章
- Function Names as Strings
[Function Names as Strings] GCC provides three magic variables that hold the name of the current fun ...
- REST Representational state transfer REST Resource Naming Guide Never use CRUD function names in URIs
怎样用通俗的语言解释什么叫 REST,以及什么是 RESTful? - 知乎 https://www.zhihu.com/question/28557115 大家都知道"古代"网 ...
- C++库研究笔记——函数名的宏定义
6.47 Function Names as Strings:http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html GCC provides th ...
- 在golang中使用 cgo,如何让被嵌入的c语言代码调用golang
https://golang.org/misc/cgo/test/callback.go // Copyright 2011 The Go Authors. All rights reserved. ...
- 高性能python
参考来源:Python金融大数据分析第八章 提高性能有如下方法 1.Cython,用于合并python和c语言静态编译泛型 2.IPython.parallel,用于在本地或者集群上并行执行代码 3. ...
- Consuming JSON Strings in SQL Server
https://www.simple-talk.com/sql/t-sql-programming/consuming-json-strings-in-sql-server/ Consuming JS ...
- clean code meaningful names
---恢复内容开始--- Meaningful Names: use Intention-Revealing Names //nice,Everyone who reads your code (in ...
- Working with Strings(使用Oracle字符串)
Working with Strings By Steven Feuerstein Part 3 in a series of articles on understanding and using ...
- Named function expressions demystified
Introduction Surprisingly, a topic of named function expressions doesn't seem to be covered well eno ...
随机推荐
- Poj 3062 Celebrity jeopardy
1.Link: http://poj.org/problem?id=3062 2.Content: Celebrity jeopardy Time Limit: 1000MS Memory Lim ...
- Unix 进程通信基本概念
一:通信分为两类: 控制信息的传递: 低级通信 大批量数据的传递: 高级通信 二:基本的通信方式 (a)主从式通信: 通信的双方存在一种隶属关系, 其中主进程是通信过程的控制者,而从进程是通信过程的从 ...
- DEDECMS中,channelartlist标签
当前频道的下级栏目的内容列表 dede:channelartlist 标签: {dede:channelartlist row=6} <dl> <dt><a href=' ...
- DTcms 扩展字段标签调用
前台模版: 文章列表:{dr[author]} 文章内容{model.fields[author]} 点击数 后台CS文件:model.fields["author"].ToStr ...
- xml直接读取节点
<root> <books> <book id="one"></book> <book id="two"& ...
- php 操作mongodb
在这里首先说一下mongo 客户端安装完成有时会启动失败 这里解决办法就是 删除 D:\mongodb\db 下的 mongod.lock文件即可 再重新启动 首先下载mongodb php扩 ...
- ARM-Linux S5PV210 UART驱动(4)----串口驱动初始化过程
对于S5PV210 UART驱动来说,主要关心的就是drivers/serial下的samsung.c和s5pv210.c连个文件. 由drivers/serial/Kconfig: config S ...
- Django的templates模版
前面介绍的都是django.http.HttpResponse 把内容直接返回到网页上,这次介绍通过渲染模版的方法来显示内容 步骤: 1.创建一个项目(略) 2.创建一个app(略) 3.添加项目到s ...
- 1018. Public Bike Management (30)
时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue There is a public bike service i ...
- Oracle的rownum原理
Oracle中,按特定条件查询前N条记录,用个rownum就搞定了: SQL> select * from dept where rownum<3; 而对rownum用"> ...