Extra bytes when declaring a member of a struct as uint32_t

后端 未结 4 1886
没有蜡笔的小新
没有蜡笔的小新 2021-01-21 10:32

I have a problem when using the uint32_t type from the stdint.h library. If I run the following code (on Ubuntu linux 11.10 x86_64, g++ version 4.6.1):

#include          


        
4条回答
  •  醉酒成梦
    2021-01-21 11:01

    Data types have different alignment requirements based on platform. The extra bytes are used to align one of the members of your structure to a particular size and/or position. IF you need more precise control, you can specify this alignment with __attribute__ or #pragma pack

提交回复
热议问题