Skip to content

Instantly share code, notes, and snippets.

@letoh
Last active August 29, 2015 14:01
Show Gist options
  • Select an option

  • Save letoh/3976d4c6fcbbe85ca489 to your computer and use it in GitHub Desktop.

Select an option

Save letoh/3976d4c6fcbbe85ca489 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#define progn(...) ({ __VA_ARGS__ ;})
#define cond0 (argc < 2)
#define cond1 (argc < 3)
#define cond2 (argc < 4)
#define cond3 (argc < 5)
#define a progn(printf("do something\n"), "a")
#define b ("b", "bb", "bbb", "bbbb")
#define c progn(\
for(int i = argc; i; --i)\
printf("i = %d\n", i);\
"c")
#define d "d"
#define e "e"
int main(int argc, char *argv[])
{
char *value =
cond0 ? a :
cond1 ? b :
cond2 ? c :
cond3 ? d :
e;
printf("value = %s\n", value);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment