function prototype with void* parameter

Viewed 2217

I have two functions, each taking a pointer to a different type:

void processA(A *);
void processB(B *);

Is there a function pointer type that would be able to hold a pointer to either function without casting? I tried to use

typedef void(*processor_t)(void*);
processor_t Ps[] = {processA, processB};

but it didn't work (compiler complains about incompatible pointer initialization).

Edit: Another part of code would iterate through the entries of Ps, without knowing the types. This code would be passing a char* as a parameter. Like this:

Ps[i](data_pointers[j]);

Edit: Thanks everyone. In the end, I will probably use something like this:

void processA(void*);
void processB(void*);

typedef void(*processor_t)(void*);
processor_t Ps[] = {processA, processB};

...

void processA(void *arg)
{
  A *data = arg;
  ...
}
3 Answers
Related