Lisp

Programmer

博客园 首页 新随笔 联系 订阅 管理
#pragma  pack(n),  where  n  is  1,  2,  4,  8,  or  16:
each  structure  member  after  the  first  is  stored  on  the  smaller  member  type  or  n-byte  boundaries.

A example will give a more direct impression:
#pragma pack(8)
struct A {
    
char c;
    
int i;
};

so sizeof(A) is 8;
while
#pragma pack(1)
struct A {
    
char c;
    
int i;
};
then sizeof(A) is 5.

PS. There is a little funny when I first encounter this preprocessor. I guess pack(8) is to force to align at 8b, but in fact the true meaning is 8B.
posted on 2006-09-13 20:45  fei  阅读(241)  评论(0)    收藏  举报