Skip to content

Instantly share code, notes, and snippets.

@iamben
Created September 30, 2012 15:10
Show Gist options
  • Save iamben/3807074 to your computer and use it in GitHub Desktop.
Save iamben/3807074 to your computer and use it in GitHub Desktop.
mem padding
#include <iostream>
union data {
struct gg_t {
char a;
char b;
int c;
} gg;
struct yy_t {
char a;
int b;
char c;
} yy;
};
int main(int argc, const char *argv[])
{
data aaa;
aaa.yy.a = 'c';
aaa.yy.b = 'c';
aaa.yy.c = 'c';
std::cout << "sizeof data: " << sizeof(data) << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment