标签:hat dna access pack bre ror efi examples cat
| Non-Confidential | ARM DUI0375E | |||
|
||||
| Home > Compiler-specific Features > #pragma pack(n) | ||||
This pragma aligns members of a structure to the minimum of and their natural alignment. Packed objects are read and written using unaligned accesses.n
#pragma pack(n) n1, 2, 4 and 8.#pragma pack(8).#pragma packed struct does not yield a __packed pointer, so the compiler does not produce an error if you assign this address to a non-__packed pointer. However, the field might not be properly aligned for its type, and dereferencing such an unaligned pointer results in undefined behavior.pack(2) aligns integer variable b to a 2-byte boundary.typedef struct
{
char a;
int b;
} S;
#pragma pack(2)
typedef struct
{
char a;
int b;
} SP;
S var = { 0x11, 0x44444444 };
SP pvar = { 0x11, 0x44444444 };
S is:
SP is:
x denotes one byte of padding.SP is a 6-byte structure. There is no padding after
b.标签:hat dna access pack bre ror efi examples cat
原文地址:https://www.cnblogs.com/qiyuexin/p/12784269.html