I developed a mechanism for function callback. This is my function.
int function_root(var1,var2, int(*callback)(), ...);
so if var1=var2 then callback(va_arg list);
For example:
function_root(a,b,fun_clbck,x,y,z); //if a=b
we will get this: fun_clbk(x, y, z);
Problem is. When my function callback have at least one argument. I get a warning incompatibility with prototype
I think the problem is in my function root. I declared int(*callback)() with zero parameter and once I do a callback like fun_clbck(int,int,int); it triggers that problem.
That’s not true.
int(*callback)()is not a C89/C99 prototype; it declares a function pointer to something returningint, without specifying types of parameters. The proper declaration for a function pointer with no arguments would beObviously. The parameter types declared for the callback function must match that in the call. Rethink your design, e.g. use a variable number of arguments:
and pass the number of actual arguments as the first parameter.