Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1359116
  • 博文数量: 277
  • 博客积分: 2551
  • 博客等级: 少校
  • 技术积分: 3918
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-21 22:46
文章分类

全部博文(277)

文章存档

2017年(3)

2016年(9)

2015年(65)

2014年(27)

2013年(85)

2012年(61)

2011年(27)

分类: C/C++

2011-03-01 22:59:38

(1)windows vc 开发平台上用#pragma pack(n),它不是对某个结构体操作,是对所有的结构的控制
(2)linux  平台上采用的是_attribute_((packed))加在结构体后面 如
struct downfile{
        char     flileText[20];
        char     fileName[20];
        unsigned int  fileLen;
}__attribute_((packed));
取消了优化对齐,按实际占用字节数进行对齐,当然另一种变化
typedef struct test_struct_2{
char         char_var;
int          int_var;
} __attribute__((packed))packed_struct;
 
更多的控制 __attribute__((__aligned__(size)));
阅读(723) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~