Skip to content

Instantly share code, notes, and snippets.

@lasconic
Created August 1, 2013 16:54
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 lasconic/6133180 to your computer and use it in GitHub Desktop.
Save lasconic/6133180 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char* argv[])
{
union U {
int subtype;
struct {
int _accidentalType:4;
int _naturalType:4;
unsigned _customType:16;
bool _custom : 1;
bool _invalid : 1;
};
};
U a;
a.subtype = 15;
printf("_accidentalType %d\n" , a._accidentalType);
printf("_naturalType %d\n" , a._naturalType);
printf("_customType %d\n" , a._customType);
printf("_custom %d\n" , a._custom);
printf("_invalid %d\n" , a._invalid);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment