摘要:        
众所周知,程序为了提高访问效率,编译器在编译的时候,进行字节对齐。程序员也可以字节指定对齐方式。Win32下的为progma指令,具体来说#pragma pack(push) //保存原对齐状态#pragma pack(4)//设定为4字节对齐struct test{ int a;};#pragma pack(pop)//恢复对齐状态在linux下,gcc是默认的编译器。g++ 支持progma指令,gcc也支持GNU扩展__attribute__指令参考《__attribute__》,对于字节对齐的举例为struct test{ short b[3];} __attribute__ ((al    阅读全文
posted @ 2011-07-06 22:14
westfly
阅读(340)
评论(0)
推荐(0)
        
 
                    
                
 浙公网安备 33010602011771号
浙公网安备 33010602011771号