GCC推荐的对齐指令:_attribute_((packed))和_attribute_((aligned(n)))
来源:互联网 发布:vmware mac 使用教程 编辑:程序博客网 时间:2024/05/19 04:03
1、使用方法
使用attribute((packed))和attribute((aligned(n)))时,直接放在类型定义的后面,那么该类型就以指定的方式进行对齐。packed的作用是取消对齐,aligned(n)表示对齐方式。
2、attribute((packed))使用实例
#include <stdio.h>struct mystruct11 { int a; char b; short c;}_attribute_((packed));struct mystruct21 { char a; int b; short c;}_attribute_((packed));int main(void){ printf("sizeof(struct mystruct11) = %d.\n",sizeof(struct mystruct11)); printf("sizeof(struct mystruct21) = %d.\n",sizeof(struct mystruct21)); /* 两个不同结构体1字节对齐的结构 struct mystruct11 struct mystruct21 1字节对齐 1字节对齐 4 1 1 4 2 2 */ return 0;}
阅读全文
0 0
- GCC推荐的对齐指令:_attribute_((packed))和_attribute_((aligned(n)))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- _attribute_((packed))
- 关于_attribute_((packed))
- gcc的_attribute_编译属性
- gcc _attribute_相关介绍
- vc下和gcc的结构体紧凑对齐格式存储【#pragma pack(push,1)、__attribute__ ((packed, aligned(1)))】
- __init _attribute_的使用
- C语言入门
- spring核心框架体系结构(jar包依赖)
- O
- P1423 小玉在游泳
- 用JS实现乘法口诀表
- GCC推荐的对齐指令:_attribute_((packed))和_attribute_((aligned(n)))
- tableview添加表头
- apiDebug-API接口调试插件,开源API接口调试插件、API & HTTP 请求调试工具
- 面试题常见算法之等概率生成随机数
- spring Ioc & Bean
- Mysql使用ON DUPLICATE KEY UPDATE批量操作
- 阿里面试
- 杭电。刘春英。老师 写给计算机软件专业的大学生
- 面向对象