Skip to content

Instantly share code, notes, and snippets.

@bitbckt
Created October 20, 2009 21:49
Show Gist options
  • Save bitbckt/214648 to your computer and use it in GitHub Desktop.
Save bitbckt/214648 to your computer and use it in GitHub Desktop.
struct foo {
int type;
#define TYPE_INT 1
#define TYPE_PAIR_OF_INTS 2
#define TYPE_STRING 3
union {
int i; // If type == TYPE_INT.
int pair[2]; // If type == TYPE_PAIR_OF_INTS.
char *str; // If type == TYPE_STRING.
} u;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment