C语言的属性:__attribute__
来源:互联网 发布:数据结构与算法知识点 编辑:程序博客网 时间:2024/05/03 00:22
1. 变量的属性
详细内容参考:变量的属性
注:
1)_attribute_后面必须为两对括号:((…))
2)属性关键字的前后也可加“_”,如aligned可为__aligned_
1.1 对齐(aligned (alignment))
指定变量或结构域的起始地址对齐(以字节为单位):
int x __attribute__ ((aligned (16))) = 0; // 16字节对齐struct foo { int x[2] __attribute__ ((aligned (8))); // 8字节对齐}; // ask the compiler to align a variable or field to // the maximum useful alignment for the target machine you are compiling forshort array[3] __attribute__ ((aligned));
1.2 紧凑型 (packed)
变量或结构域以最小对齐单位对齐,如变量以字节对齐,结构域以位对齐:
struct foo { char a; int x[2] __attribute__ ((packed)); // it immediately follows a };
1.3 指定代码段(section (“section-name”))
把变量或函数放于指定的代码段:
struct duart a __attribute__ ((section ("DUART_A"))) = { 0 }; struct duart b __attribute__ ((section ("DUART_B"))) = { 0 }; char stack[10000] __attribute__ ((section ("STACK"))) = { 0 }; int init_data __attribute__ ((section ("INITDATA"))) = 0; main() { /* Initialize stack pointer */ init_sp (stack + sizeof (stack)); /* Initialize initialized data */ memcpy (&init_data, &data, &edata - &data); /* Turn on the serial ports */ init_duart (&a); init_duart (&b); }
1.4 向量尺寸(vector_size (bytes))
指定向量的大小,以字节为单位:
int foo __attribute__ ((vector_size (16))); int foo __attribute__ ((__vector_size__ (16))); struct S { int a; }; struct S __attribute__ ((vector_size (16))) foo;
2. 函数的属性
详细内容参考:函数的属性
3. 类型的属性
详细内容参考:类型的属性
typedef int more_aligned_int __attribute__ ((aligned (8)));typedef long HEXAGON_VecPred128 __attribute__((__vector_size__(128))) __attribute__((aligned(128)));
0 0
- C语言的属性:__attribute__
- C语言的__attribute__机制
- C语言__attribute__的使用
- C语言中__attribute__的作用
- C语言中__attribute__的用法
- c语言中__attribute__的意义
- c语言中__attribute__的意义
- C语言__attribute__
- 【C语言】[其他]:C语言的 __attribute__ 用法
- gcc 的__attribute__ 属性
- C语言中的__attribute__机制
- C语言中的__attribute__机制
- C语言中的__attribute__机制
- C语言中的__attribute__机制
- C语言中的__attribute__机制
- gnu C语言__attribute__作用
- C语言基本 关键词__attribute__
- GNU C语言的 扩展(七)__attribute__测试
- 纯CSS实现图片水平垂直居中于DIV(图片未知宽高)
- Android应用启动黑屏、白屏解决方法
- 域名解析基础知识(NS,A记录,CNAME,MX)
- zoj1619
- 你的团队健康吗?如何打造一支健康的团队?
- C语言的属性:__attribute__
- 为什么你有10年经验,但成不了专家?
- zoj1622
- Android中设置ListView的item高度无效--解决方案
- Vue.js 2.0新增的虚拟DOM是怎么回事?
- Unity 操纵方块碰撞其他物体 使其他物体变色
- 不安装oracle客户端,pl/sql developer 远程连接oracle
- 深入浅出设计模式之建造模式
- Windows驱动开发报错集锦