我在 C 中有以下嵌套结构。(64 位)
typedef struct {
int a;
int b;
int c;
struct {
int ab;
long bc;
}
int d;
} Test;
I see that,
a = 4 bytes
b = 4 bytes
c = 4 bytes
padding1 = 4 bytes
inner structure = 16 bytes ( 4 bytes for ab, 4 bytes padding, 8 bytes for bc)
d = 4 bytes
padding2 = 4 bytes
Run Code Online (Sandbox Code Playgroud)
sizeof(Test) 返回 40 个字节。
我的问题:
padding1 -> 为什么是 4 个字节?这是因为内部结构本身应该对齐吗?。(此外,它是否与 8 字节(长)或 …