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個字節的東西?有種迷失在這裏。
非常好!謝謝,你會碰巧想知道我如何對齊這個整數數組嗎?不是每個第四個條目都必須是空的或類似的東西嗎? –