views:

28

answers:

2

Hello,

Here's an example of what i'm trying to achieve. I'm trying to create a macro, that would look like this:

SOMEMACRO(obj, obj, obj, ..., obj);

The macro would compile to:

some_function(obj, obj, obj, ..., obj, SOMETHING_ELSE, SOMETHING_ELSE);

Here's an example macro for a 1 parameter function:

#define SOMEMACRO(x) some_function(x, SOMETHING_ELSE, SOMETHING_ELSE)

But it only works with one parameter (x)

So basically i need the same thing but so that i could pass a viariable number of arguments. It would be nice that the compiler took whatever is between ( and ) and simply replaced X with it. I'm not sure if i was very clear about the problem, but i hope you understood.

Thanks for any help.

A: 

Sorry, i gave up on searching too early i guess. To answer my own question:

The macro for a variadic function looks like this:

#define MACRONAME(...) some_function(__VA_ARGS__, SOMETHING_ELSE, SOMETHING_ELSE)
Marius
A: 
#define SOMEMACRO(...) some_func(__VA_ARGS__, SOMETHING_ELSE, SOMETHING_ELSE);
Jason Foreman