下面是一个结构体位域,结构体变量的内存大小不应该是8Byte吗,为什么是4Byte?

#include <stdio.h>
struct EIGHT_BYTE
{
    unsigned char ccc1 : 1;
    unsigned int ccc2 : 1;
} eight_byte;

int main(int argc, char const *argv[])
{
    printf("sizeof one_byte is : %lu\n", sizeof(one_byte));
    printf("sizeof two_byte is : %lu\n", sizeof(two_byte));
    printf("sizeof three_byte is : %lu\n", sizeof(three_byte));
    printf("sizeof four_byte is : %lu\n", sizeof(four_byte));
    printf("sizeof eight_byte is : %lu\n", sizeof(eight_byte));
    return 0;

sizeof eight_byte is : 4

我在vs2019上测试 大小是8啊

img

你放的代码不全,比如什么four_byte之类的根本没定义
那么我很有理由怀疑你的struct其实也省略了某些关键的东西没放出来,比如union

难道是使用的机器不一样导致的吗?
我的是64位的linux虚拟机