Is there a way to disable certain errors under VS2008?

吃可爱长大的小学妹 提交于 2020-06-29 07:39:05

问题


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++ ?


回答1:


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.



来源:https://stackoverflow.com/questions/23104646/is-there-a-way-to-disable-certain-errors-under-vs2008

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!