Chinaunix

标题: __attribute__ ((packed)) idtr; 如何理解. [打印本页]

作者: hades555    时间: 2006-02-08 16:17
标题: __attribute__ ((packed)) idtr; 如何理解.
struct {
unsigned short limit;
unsigned int base;
} __attribute__ ((packed)) idtr;

看到有人这样写. __attribute__ ((packed)) idtr; 是什么意思.如何理解?请教
作者: albcamus    时间: 2006-02-08 16:20
告诉编译器:不要对齐。

你可以自己试验, 比对同样的结构, 有无packed属性, 其sizeof值是否一样。
作者: hades555    时间: 2006-02-08 16:23
好.谢谢斑竹.我现在就去看看
作者: jeffshia    时间: 2006-02-09 00:47
是要对齐。
作者: richardhesidu    时间: 2006-02-09 02:45
取消结构在编译过程中的优化对齐,按照实际占用字节数进行对齐。

both of you are right !

作者: jeffshia    时间: 2006-02-09 11:19
right




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2