Skip to content

Instantly share code, notes, and snippets.

@xNWDD
Last active February 12, 2017 02:15
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 xNWDD/3dd711a96d7ebff1249868f25e1e3ea6 to your computer and use it in GitHub Desktop.
Save xNWDD/3dd711a96d7ebff1249868f25e1e3ea6 to your computer and use it in GitHub Desktop.
#define wdwuc(X,Y) X##Y
#define wdwu(type,condition,counter) if(type) goto wdwuc(dowhile,counter); else while (condition) wdwuc(dowhile,counter):
#define wdw(type,condition) wdwu(type,condition,__COUNTER__)
#include <cstdio>
const char * strings[]{ "1", "2" , "3", 0 };
char * getpacket(){
static int i = 0;
if(!strings[i-1])
i = 0;
return const_cast<char*>(strings[i++]);
}
void TEST1(char * msg) {
wdw(msg,msg=getpacket()){
printf(msg);
}
wdw(false,false)
while(false)
wdw(false,false) for(;;)
printf("");
}
int main() {
TEST1(0); //123
puts("");
TEST1(const_cast<char*>("0")); //0123
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment