Created
January 9, 2013 08:57
-
-
Save Javran/4491685 to your computer and use it in GitHub Desktop.
call functions that share one argument without indicating what the argument is repeatedly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
void print3arg(int a, int b, int c) | |
{ | |
printf("a=%d, b=%d, c=%d\n", a, b, c); | |
} | |
void print2arg(int a, int b) | |
{ | |
printf("A=%d, B=%d\n", a, b); | |
} | |
int main() | |
{ | |
#define _EXEC(FUNC, ...) FUNC(arg, __VA_ARGS__) | |
int arg = 1; | |
_EXEC(print3arg, 2, 3); | |
_EXEC(print2arg, 4); | |
{ | |
int arg = 2; | |
_EXEC(print3arg, 2, 3); | |
_EXEC(print2arg, 4); | |
} | |
_EXEC(print2arg, 4); | |
#undef _EXEC | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment