Reset struct alignment back to standard after each #pragma pack (n)
When using #pragma pack (n) to change the alignment for a struct to n bytes, it is necessary to reset the alignment to the standard value as otherwise the changed alignment is used throughout the whole program code which causes other structs to become unaligned.
This commit is contained in:
@@ -34,6 +34,7 @@ struct TempMBR {
|
||||
struct MBRRecord partitions[4];
|
||||
uint16_t MBRSignature;
|
||||
}; // struct TempMBR
|
||||
#pragma pack ()
|
||||
|
||||
// Possible states of the MBR
|
||||
enum MBRValidity {invalid, gpt, hybrid, mbr};
|
||||
|
||||
1
bsd.h
1
bsd.h
@@ -89,5 +89,6 @@ class BSDData {
|
||||
int GetNumParts(void);
|
||||
GPTPart AsGPT(int i); // Return BSD part. as GPT part.
|
||||
}; // struct MBRData
|
||||
#pragma pack ()
|
||||
|
||||
#endif
|
||||
|
||||
1
gpt.h
1
gpt.h
@@ -57,6 +57,7 @@ struct GPTHeader {
|
||||
uint32_t partitionEntriesCRC;
|
||||
unsigned char reserved2[GPT_RESERVED];
|
||||
}; // struct GPTHeader
|
||||
#pragma pack ()
|
||||
|
||||
// Data in GPT format
|
||||
class GPTData {
|
||||
|
||||
Reference in New Issue
Block a user