Skip to content

Instantly share code, notes, and snippets.

@AtnNn
Created May 15, 2012 04:19
Show Gist options
  • Save AtnNn/2699087 to your computer and use it in GitHub Desktop.
Save AtnNn/2699087 to your computer and use it in GitHub Desktop.
foo(BAR, 42); foo(QUX, "hallo")
#include <stdio.h>
union zig {
int num;
char *str;
};
enum pop { BAR, QUX };
void foo_ (enum pop p, union zig z){
putchar( p == BAR ? z.num : z.str[0] );
}
#define foo(p, z) foo_(p, (union zig) z)
int main(){
foo(BAR, 90);
foo(QUX, "\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment