oh, my god

这写程序也写了有几万行了吧,竟然没有认真的考虑过程序的平台可移植性,今天就糗了一个。给大家提个醒。

代码这样写

typedef struct test_a_struct

{

     unsigned int a      : 1;

}TEST_A_STRUCT;

 

typedef struct test_b_struct

{

     unsigned int b      : 1;

}TEST_B_STRUCT;

 

typedef struct test_c_struct

{

       TEST_A_STRUCT  var1;

       TEST_B_STRUCT  var2;

}TEST_C_STRUCT;

 

sizeof(TEST_C_STRUCT) 是多少?

 

你能得到答案吗?不同的编译器会给出不同的答案。所以 不要这样写代码,不要怕麻烦,补齐就可以了。

typedef struct test_a_struct

{

     unsigned int a           : 1;

     unsigned int unused  :31

}TEST_A_STRUCT;

 

typedef struct test_b_struct

{

     unsigned int b          s  : 1;

     unsigned int unused  :31

}TEST_B_STRUCT;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值