void*
means (effectively) "a pointer to an untyped region of memory".
void**
means (effectively) "a pointer to a region of memory, which contains pointers to untyped regions of memory".
Notice how the block in the middle has a type -- an array of void*
. You're passing in effectively an array of mystruct*
, which is a different type. So your compiler warns you.
Similar issues occur in C++ when trying to convert Derived**
to Base**
; but it applies here in C as well. (void*
operates like the "base class" of all pointer types) Consider a piece of code like this:
void does_things(void** outParameter)
{
*outParameter = malloc(42); // Looks fine; writing void* to void* :)
}
int main()
{
my_struct* x = /*...*/;
does_things(&myStruct); // Ut oh, tries to make x point to
// something that is *not* a my_struct
}