What is happening here is that most likely you are inadvertently compiling your code as C++ code. In C++ (as opposed to C) void *
is not implicitly convertible to other pointer types.
It you intend to write your code in C, make sure you compile it as C. It you intend to write your code in C++, you will have to use explicit type conversion operators to convert void *
pointers to other pointer types.
The conversion to long *
pointer type probably happens in other translation unit (i.e. other file), which is compiled as C. That is probably why it succeeds.
Note that compilers can use C and C++ mode independently for each translation unit. Many compilers will choose between C and C++ based on file extension, compiling .c
files as C and .cpp
files as C++.