Reputation: 313
I have something like this:
void vectorDestroyWithItems(Vector *vector, void (*destroyItemFunc)(void*));
void myTypeDestroy(MyType *obj);
and I want to call it in this way:
vectorDestroyWithItems(vector, myTypeDestroy);
But I get error:
argument of type "void (*)(MyType MyType)" is incompatible with parameter of type "void ()(void *)
Why is it illegal?
Upvotes: 0
Views: 27
Reputation: 2567
void (*destroyItemFunc)(void*)
---> Function pointer, which takes void*
as argument and do not return any value.
But ,void myTypeDestroy(MyType *obj);
, here the argument is of type MyType *
, not void*
. This is the reason for error.
Solution : Use this
void vectorDestroyWithItems(Vector *vector, void (*destroyItemFunc)(MyType *));
Upvotes: 2