C allows an implicit conversion between void* and any pointer to an object type, C ++ does not. To make your code compatible with both languages, you can enter foo( (void*)&a ); .
However, using void pointers is not recommended in both languages - they should be used only as a last resort. If you want the function to be typical of C, you should use the _Generic keyword. In C ++ you use templates.
source share