我的代码过去可以正常工作,但现在结构体大小突然变为 16 字节。它曾经是 13 个字节。我最近从 Xcode 4.2 升级到 Xcode 4.3.1 (4E1019)。
#pragma pack(1)
struct ChunkStruct {
uint32_t width;
uint32_t height;
uint8_t bit_depth;
uint8_t color_type;
uint8_t compression;
uint8_t filter;
uint8_t interlace;
};
#pragma pack()
STATIC_ASSERT(expected_13bytes, sizeof(struct ChunkStruct) == 13);
我尝试使用不成功
#pragma pack(push, 1)
/* struct ChunkStruct { ... }; */
#pragma pack(pop)
我也尝试了以下方法,但没有运气
struct ChunkStruct {
uint32_t width;
uint32_t height;
uint8_t bit_depth;
uint8_t color_type;
uint8_t compression;
uint8_t filter;
uint8_t interlace;
} __attribute__ ((aligned (1)));
如何使用 Xcode 4.3.1 打包结构?