One of the best (but little known) features of GNU C is the __attribute__ mechanism, which allows a developer to attach characteristics to function declarations to allow the compiler to perform more error checking. It was designed in a way to be compatible with non-GNU implementations, and we've been using this for years in highly portable code with very good results.
Table of Contents
- __attribute__ format
- __attribute__ noreturn
- __attribute__ const
- Putting them together
- Compatibility with non-GNU compilers
- Other References
Note that __attribute__ spelled with two underscores before and two after, and there are always two sets of parentheses surrounding the contents. There is a good reason for this - see below. Gnu CC needs to use the -Wall compiler directive to enable this (yes, there is a finer degree of warnings control available, but we are very big fans of max warnings anyway).
分享到:
相关推荐
GNU_CC中的attribute有助于你对于gnu c中的内容深入理解
本课程是《C语言嵌入式Linux编程》第5期主要内容包括:Linux内核、驱动程序中,GNU C对标准C扩展的大量的语法。学员在掌握这些扩展语法的基础上,消除阅读Linux内核、驱动、GNU开源软件的障碍。能够看懂这些“稀奇...
目录 1.1 体系架构 3 1.1.1 Linux体系结构 4 1.1.2 一般程序的执行 5 ...1.6 __attribute__ 机制 46 1.6.1 函数属性 46 1.6.2 变量属性 51 1.6.3 类型属性 52 1.6.4 变量属性与类型属性举例 54 1.7 必要的编译知识 55
smallblock.c:19: In function ‘open’, inlined from ‘nandflash_sb_setup’ at nandflash/nandflash_smallblock.c:519:24: /usr/include/x86_64-linux-gnu/bits/fcntl2.h:50:4: error: call to ‘__open_missing...
Ubuntu下libxml2的交叉...test: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.14, not stripped rootroot@rootroot-virtual-machine:~/wyb$
PEP 520: Preserving Class Attribute Definition Order PEP 468: Preserving Keyword Argument Order New dict implementation PEP 523: Adding a frame evaluation API to CPython PYTHONMALLOC environment ...
注意:C ++异常,RTTI,全局外部变量,线程本地存储,全局构造函数和析构函数(ELF .ctors / .dtors / attribute((con-/destructor))事物,而不是C ++语言构造),...还不被支持,并且可能不会很快出现。 # example...
1.Hyper Estraier是一个用C语言开发的全文检索引擎,他是由一位日本人开发的.工程注册在sourceforge.net(http://hyperestraier.sourceforge.net). 2.Hyper的特性: 高速度,高稳定性,高可扩展性…(这可都是有原因的,...
q或Ctrl+C 退出; /字符串 从上往下查找匹配的字符串; ?字符串 从下往上查找匹配的字符串; n 继续查找。 四、退出命令 exit 退出; DOS内部命令 用于退出当前的命令处理器(COMMAND.COM) 恢复前一个命令...
4 实验过程及结果 应用iris.arff数据集,分别采用LibSVM、C4.5决策树分类器和朴素贝叶斯分类器进行测试和评价,分别在训练数据上训练分类模型,找出各个模型最优的参数值,并对三个模型进行全面评价比较,
4实验过程及结果 应用iri.arff数据集,分别采用LibSVM、C4.5决策树分类器和朴素贝叶斯分类器进行测试和评价,分别在训练数据上训练分类模型,找出各个模型最优的参数值,并对三个模型进行全面评价比较,得到一个最