Reputation: 1292
This may sound confusing, but how can you pass MULTIPLE ARGUMENTS in one ARGUMENT.
What I've tried is the following:
#define CALL(v, look, param, expect) v(param){look(expect);}
Example when using it (Doesn't work):
void CALL(InitD3D, engine->InitD3D, (HWND hWnd, bool windowed), (hWnd, windowed))
// Which should give(i want it to):
// void InitD3D(HWND hWnd, bool windowed){engine->InitD3D(hWnd, windowed);}
// But it may give: InitD3D((HWND hWnd, bool windowed)){engine->InitD3D((hWnd, windowed));}
// Or something similar or not...
So is basic words, how can i pass multiple arguments in one argument, without screwing it up...
Thank You
Upvotes: 1
Views: 3931
Reputation: 44488
The simplest way to pass more than one argument in is to use a structure.
Example:
typedef struct{
int arg1;
std::string arg2;
int arg3;
} fn_args;
void bob( fn_args a )
{
//access them using a.arg1, a.arg2, etc.
}
EDIT: You mentioned VA_ARGS. That is used when the number of arguments you want to pass in is variable. You can usually solve most problems without needing to use VA_ARGS.
Another technique you might want to look at is called the Named Parameter Idiom, which is more about not caring which order the function arguments are passed in. Since its not entirely clear what you're trying to do here, I've given you a few possible approaches.
Upvotes: 1
Reputation: 275878
#define CALL(v, look, param, expect) v param {look expect;}
namespace foo {
void bob(int x, int y) {}
}
CALL(void bob, foo::bob, (int x, int y), (x,y))
int main() {
bob(7,2);
}
I would advise against this technique.
Upvotes: 1