Skip to content

Instantly share code, notes, and snippets.

@codebrainz
Created May 9, 2018 02:06
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 codebrainz/ed2daede5e9ad4743317e3ae3670fbed to your computer and use it in GitHub Desktop.
Save codebrainz/ed2daede5e9ad4743317e3ae3670fbed to your computer and use it in GitHub Desktop.
struct A {
uint8_t x:4;
uint8_t :4;
};
struct B {
uint16_t x:4;
uint16_t :12; // ...
};
void *mem = malloc(16);
struct A *a = (struct A*)mem;
struct B *b = (struct B*)mem;
assert(a->x == b->x);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment