此联合的大小返回16个字节(在C ++ Builder 2007中)。
typedef union
{
struct
{
unsigned Type:2;
unsigned Prev:31;
unsigned Next:31;
unsigned SizeInBytes:32;
};
} eMyUnion;
如果我想要sizeof(eMyUnion)= 12个字节,我必须如何修改这个联合定义? (我想保留这些字段及其大小,但可以重新排序) 有可能吗?
答案 0 :(得分:1)
#pragma pack(push, 1)
struct
{
unsigned Type:2;
unsigned Prev:31;
unsigned Next:31;
unsigned SizeInBytes:32;
};
#pragma pack(pop)