Question

I'm trying to compile a lot of legacy C (C99) code using VS2008. To solve some issue with the C99 code not support by the VS2008 compiler, I switched to the C++ compiler, but I'm now facing another issue with the C++ casting error:

 error C2440: '=' : cannot convert from 'void *' to 'uint8_t *'
 Conversion from 'void*' to pointer to non-'void' requires an explicit cast

Is there a setting on the C++ compiler to disable that error and allow C-style cast when build in C++ ?

Was it helpful?

Solution

There's no way to disable these errors. These are hard errors defined by the language. You cannot pick and choose which parts of the core language that you want to adhere to. If these were vendor specific extensions then there may be options to disable them, but that's not the case. These errors relate to fundamental rules of the C++ language.

My recommendation is to compile this code with a true C99 compiler. Any attempt to compile it with MSVC 2008 (either as C or C++) will lead to disappointment and pain.

It is plausible that the very latest version of MSVC would fare better with this code. In recent releases of MSVC Microsoft have improved support for C99 when compiling as C. This support for C99 is not complete, but it may be enough to compile your code correctly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top