0
我有这个结构,但知道每个第四个字节没有在内存中使用,我需要在内存中正确地对齐结构。我不完全确定如何做到这一点,虽然我知道我应该和我也知道其中它需要发生。如何在PIC24芯片的结构中对齐变量?
typedef struct _vol_meta {
uint16_t crc; // 2 bytes
uint8_t ver_major; // 1 byte
char pad1; // need to align here - 1 byte
uint16_t size; // 2 bytes
uint8_t ver_minor; // 1 byte
char pad2; // need to align here - 1 byte
uint8_t pagenum; // 1 byte
uint8_t rownum; // 1 byte
char pad3[2]; // align here - 2 bytes
uint8_t name[15]; // 15 bytes
// not sure how I'm supposed to align the array of uint8_t vars?
} VOL_META;
是否有某种C数据类型的像
align 2
告诉编译器跳过接下来的2个字节的东西?有种迷失在这里。
非常好!谢谢,你会碰巧想知道我如何对齐这个整数数组吗?不是每个第四个条目都必须是空的或类似的东西吗? –