C++笔记: __attribute__的使用
来源:互联网 发布:网络高清机顶盒哪个好 编辑:程序博客网 时间:2024/05/29 19:20
GCC使用__attribute__关键字来描述函数,变量和数据类型的属性,用于编译器对源代码的优化。
描述函数属性的几个重要的关键字:
- void noreturnfun() __attribute__((noreturn));//函数不会返回。
- void centon() __attribute__((alias("__centon")));//设置函数别名,函数是__cencon,别名是centon.
- void main_enter() __attribute__((constructor));//main_enter函数在进入main函数前调用
- void main_exit() __attribute__((destructor));//main_exit函数在main函数返回后调用
- void fun() __attribute__ ((noinline));//fun函数不能作为inline函数优化
- void fun() __attribute__ ((section("specials”)));//将函数放到specials段中,而不是通常的text段中
- no_instrument_function、constructor和destructor关键字主要用于剖析(profiling)源代码的。
- __attribute__(format(archetype,string-index,first-to-check)): format attribute提供了依照printf, scanf, strftime, strfmon类型函数的参数格式对目标函数进行类型的检查.
- __attribute__((weak)): weak symbol,弱符号. 若存在两个相同的全局符号时,会引发重定义错误. 如果使用weak attribute,则当weak symbol和non-weak symbol同时存在的时候,linker会使用non-weak symbol.若只有weak symbol存在的时候则只使用weak symbol.
- __attribute__((deprecated)): deprecated,弃用. 如果在源文件在任何地方地方使用deprecated attribute函数,编译器将会发出警告.
- __attribute__((aligned(ALIGNMENT))): 指定变量或结构体最小字节对齐数,以byte为单位.ALIGNMENT: 指定的字节对齐操作数.
- __attribute__((cleanup(cleanup_function)): 当一个变量的作用域消失时,便会执行后面的clean_function函数.
- __attribute__((packed)): 使变量或者是结构体按照最小的对齐方式,对于变量是1byte对齐,对于字段,也就是field指bit对齐.
0 0
- C语言__attribute__的使用
- C++笔记: __attribute__的使用
- GNU C——__attribute__的使用
- __attribute__的使用
- GUN的__attribute__使用
- GNU C 的 __attribute__ 机制
- GNU C 的 __attribute__ 机制
- GNU C 的 __attribute__ 机制
- GNU C 的 __attribute__ 机制
- GNU C的__attribute__机制
- GNU C 的 __attribute__ 机制
- GNU c的__attribute__ 机制
- GNU C的__attribute__机制
- C语言的__attribute__机制
- C语言的属性:__attribute__
- 有关__attribute__的相关使用
- __attribute__使用的一些总结
- __attribute__使用的一些总结
- Kinect For Windows SDK 2.0的解读之《KinectV2开发手册》
- UIApplication详解
- Project Eluer - 22
- 使用自定义Adapter后 ListView刷新问题
- ORA-01502 oracle数据库 index索引的两种形式
- C++笔记: __attribute__的使用
- Freeswitch架构
- Lucene基础篇1 概论
- Spark SQL 1.2(building-spark1.2, sparksql on hive,spark-sql)
- Jquery getJSON方法分析(一)
- Comparable接口实现和使用方法介绍
- 使用Ant批量打包Android应用完全指南
- Linux下Mysql自启动
- 在Linux下adb连接不上android手机的终极解决方案