I'm trying to figure out how to write a C Preprocessor macro that can accept a partial function name and a piece of text to append to the function name along with a set of arguments to create the actual function name and function call. The idea is to combine the first two macro arguments to create a function name and then add the rest of the macro arguments as arguments for the function name created.
So I want to achieve the following:
MACRO(foo, postfix, ...)
----> foo_postfix(__VA_ARGS__)
For instance if I have several C functions, func_test1() and func_test2() and func_test3() then I want to be able to use the macro to specify func as the first argument and test1 as the second argument so that the macro will create a function name of func_test1(), or to specify func as the first argument and test2 as the second argument so that the macro will create a function name of func_test2.
or something like
#define MACRO(foo,postfix,...) "macro to combine foo and postfix into actual function name"
and then I could use this macro like
MACRO(func, test1, a, b, c); // will create func_test1(a, b, c);
MACRO(func, test2, i, x); // will create func_test2(i, x);
There doesn't seem to be a straightforward way to do this.