Skip to content

Instantly share code, notes, and snippets.

@cfr
Last active August 29, 2015 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cfr/0955b4cb4b86b842d6f3 to your computer and use it in GitHub Desktop.
Save cfr/0955b4cb4b86b842d6f3 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef struct {
char her;
long double hear[16];
int hero;
float yo[17];
} A;
#pragma pack(1)
typedef struct Apack {
char her;
long double hear[16];
int hero;
float yo[17];
} Apack;
int main() {
{
A s;
printf("%zu = char: %zu, ldouble[16]: %zu, int: %zu, float[17]: %zu\n"
, sizeof(s), sizeof(s.her), sizeof(s.hear)
, sizeof(s.hero), sizeof(s.yo));
}
{
Apack s;
printf("%zu = char: %zu, ldouble[16]: %zu, int: %zu, float[17]: %zu\n"
, sizeof(s), sizeof(s.her), sizeof(s.hear)
, sizeof(s.hero), sizeof(s.yo));
}
#pragma options align=reset
{
A s[7];
printf("%zu\n", sizeof(s));
}
Apack s[7];
printf("%zu\n", sizeof(s));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment