I have a function takes parameters as arrays. I also give array values with anonymous array initialization such as
myfunction(char[]{1,1,1,0},int[]{2,2,0});
myfunction scans each array till find zero element. Different size of arrays acceptable as you put zero to the end of array.
I need a C macro to wrap that myfunction.
#define WRAP_MY_FUNCTION(X,Y) myfunction(int[]X,char[]Y)
And wish to use such as :
WRAP_MY_FUNCTION({1,1,1,0},{2,2,0})
to obtain my function :
myfunction(char[]{1,1,1,0},int[]{2,2,0})
But compiler says that you enter 7 parameters but expected 2 parameters. Then i tried variadic arguments as below:
#define WRAP_MY_FUNCTION(...) myfunction(int[]__VA_ARGS__,char[]__VAR_ARGS__)
but as is seen above in this method it is not possible to make distinct VA_ARGS expressions for each array initialization.
Is it possible to realize such an implementation with C macro usage ?
NOTE : my primary intention in this macro usage was for anonymous array initialization, exactly i do NOT want to define structs such as int x[4]={1,1,1,0}; int y[3]={2,2,0} .. etc as is seen from my question. I wish to write macro as below
WRAP_MY_FUNCTION({1,1,1,0},{2,2,0})
M Oehm and Florian Weimer thanks for your answers. They are acceptable, but for now i am willing to listen new answers also. In especially as noted M Oehm , my aim was to hide 0 at the end of the arrays.