What is VC++ doing when packing bitfields?

前端 未结 5 713
既然无缘
既然无缘 2020-12-03 23:01

To clarify my question, let\'s start off with an example program:

#include 

#pragma pack(push,1)
struct cc {
    unsigned int a   :  3;  
            


        
5条回答
  •  情歌与酒
    2020-12-03 23:45

    Well you are using unsigned int which happens to be 32 Bit in this case. The next boundary (to fit in the bitfield) for unsigned int is 64 Bit => 8 Bytes.

提交回复
热议问题