TransWikia.com

the identifier __VA_ARGS__ can only appear in the replacement lists of variadic macros

Stack Overflow Asked by Meme Machine on November 27, 2021

I am attempting to create a macro to perform api calls. My current issue is the passing of parameters for the call. I get the following error message:

the identifier __VA_ARGS__ can only appear in the replacement lists of variadic macros

#define DO_CALL(api_name)(...) wow64hg::do_call(FNV(#api_name), __VA_ARGS__)

const auto status = DO_CALL(TerminateProcess)(process_handle, 0);

It technically may be possible to fix this by using operator loading, but I am confident there should be a way to keep it simple like this and get it to work.

One Answer

Variadic macro syntax doesn't work like that; the ... has to represent additional arguments of the macro. A macro can't take multiple sets of arguments in separate sets of parentheses like an iterated function call.

I think you have to do the following:

#define DO_CALL(api_name, ...) wow64hg::do_call(FNV(#api_name), __VA_ARGS__)

const auto status = DO_CALL(TerminateProcess, process_handle, 0);

Answered by Nate Eldredge on November 27, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP