I would like to know if it is possible to use a specific operator in a macro definition
I have a macro where it works fine
It is as follows:
#define TestMacroDefine(i, ...) \
Start->Client(i, __VA_ARGS__);
Example of use:
TestMacroDefine(pck->i, &pck->len);
As you can see I use the & operator, is there any way I can migrate this operator to the macro definition?
do something like:
#define TestMacroDefine(i, ...) \
Start->Client(i, &__VA_ARGS__);
CodePudding user response:
Yes (leave out the last ;
of the macro though):
#define TestMacroDefine(i, ...) Start->Client(i, &__VA_ARGS__)
int main() {
TestMacroDefine(pck->i, pck->len);
}
will expand to what you wanted:
$ cpp 1.c
...
int main() {
Start->Client(pck->i, &pck->len);
}