在位域中,为什么中间有些位是空的?

use*_*398 6 c

定义位字段时,可以在中间保留一些位空白,并将成员分配给特定位。为什么中间有些空位?

struct product {
    unsigned int code : 6;    // product code : 6 bit
    unsigned int : 10;    // not use 10 bit
    unsigned int color : 5;    // product color : 5 bit
    unsigned int : 5;    // not use 5 bit
    unsigned int size : 6;    // product size : 3 bit
};
Run Code Online (Sandbox Code Playgroud)

我不知道为什么我不使用中间的钻头

Dee*_*top 5

位域的结构可避免跨越字和字节边界。前两个,6和10位加起来为16位,而其他三个,5、5和6也加起来为16位。将一个位字段作为2个单独的16位字的一部分可能是非常低效的。