C 联合/结构数据类型和位字段引用速度
使用以下union typedef,访问MyPacket.Byte.LB与访问MyPacket.Field.LB的速度是否有差异C 联合/结构数据类型和位字段引用速度,c,struct,bit-fields,unions,C,Struct,Bit Fields,Unions,使用以下union typedef,访问MyPacket.Byte.LB与访问MyPacket.Field.LB的速度是否有差异 typedef union // create a union to assemble bytes into ints { int Packet; // contains an int struct { char HB; char LB; }Byte; struct { unsigned
typedef union // create a union to assemble bytes into ints
{
int Packet; // contains an int
struct
{
char HB;
char LB;
}Byte;
struct
{
unsigned field1:4;
unsigned field2:2;
unsigned field3:1;
unsigned field4:1;
unsigned LB:8;
}Field;
} packetunion;
包联合我的包 唯一确定的方法是对两个版本进行编码,并在目标系统上对它们进行分析,以进行多个编译器优化设置。如果你看到了可测量的差异,我真的会感到惊讶