Skip to content

Instantly share code, notes, and snippets.

@kkabdol
Last active February 12, 2016 16:55
Show Gist options
  • Save kkabdol/831d0be4d47e225c7f1a to your computer and use it in GitHub Desktop.
Save kkabdol/831d0be4d47e225c7f1a to your computer and use it in GitHub Desktop.
#pragma pack(1)
#pragma pack(1)
struct s_t { // sizeof s_t = 11
char a; // offset = 0, align = 1
int b; // offset = 1, align = 1
short c; // offset = 5, align = 1
int d; // offset = 7, align = 1
}S;
#pragma pack()
struct s_t { // sizeof s_t = 11
char a; // offset = 0, align = 1
int b; // offset = 4, align = 4
short c; // offset = 8, align = 2
int d; // offset = 12, align = 4
}S;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment