Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 联合/结构数据类型和位字段引用速度_C_Struct_Bit Fields_Unions - Fatal编程技术网

C 联合/结构数据类型和位字段引用速度

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

使用以下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    field1:4;
    unsigned    field2:2;
    unsigned    field3:1;
    unsigned    field4:1;
    unsigned    LB:8;
    }Field;
} packetunion;

包联合我的包

唯一确定的方法是对两个版本进行编码,并在目标系统上对它们进行分析,以进行多个编译器优化设置。如果你看到了可测量的差异,我真的会感到惊讶