I am developing a thread pool in c language and i wanted to allow a task to have an arbitrary number of arguments. Even-thought i could use a function like
int (*task) ();
This function would be able to be called with any type of arguments, like for example i could do
int fib(int n) { return n < 2 ? n : fib(n-1) + fib(n-2); }
...
task = fib;
printf("fib(10)=%d\n",task(10));
However what I want is to be able to save the arguments to run it later, without having to use a call to malloc, because otherwise i would prefer to just use a task like
void * (*task) (void *);
in which i would only have to save the void * argument on a struct. However i wanted to do that for arbitrary arguments, is it possible to make it automatically for any kind of functions i want, without even using any va_list.
Is it possible?
tx in advance