我有以下代码:
typedef unsigned short u16;
struct S {
struct {
u16 a: 9;
u16 b: 1;
u16 c: 1;
u16 d: 1;
} __attribute__((packed));
u16 e: 4;
} __attribute__((packed));
当我检查时sizeof(S)
,它返回 3。是否有可能以某种方式指示 gcc 跨匿名结构合并位域,以便sizeof(S)
返回 2。