struct { unsigned char x1 : 2; unsigned char x2 : 2; unsigned char x3 : 2; unsigned char x4 : 2; } Bunch; /* sizeof(Bunch) => 1 */
struct { unsigned char x1: 2; unsigned char x2: 2; unsigned char : 0; /* 下一个位域在内存分配边界对齐 */ unsigned char x4: 2; } Bunch; /* sizeof(Bunch) => 2 */
参考:http://www.qtbig.com/page/5/