warning C4995 vs error C4995

让人想犯罪 __ 提交于 2019-12-20 02:30:29

问题


When I build a project (with VS2012) I get folowing output several times:

 warning C4995: 'DwmEnableComposition': name was marked as #pragma deprecated

When I copy the projects sourcefiles into another project (and different solution) I get errors instead of warnings (and the build does not succeed):

error C4995: 'DwmEnableComposition': name was marked as #pragma deprecated

Is there anything I can do that I get warnings instead of errors?

That is the project I am running (it's not my own code): http://federico-mammano.github.io/Oculus-SDK-0.4.4-beta-OpenGL-Demo/ (the OpenGL example)


回答1:


You probably have 'SDL checks' enabled for the project where you get an error (under C/C++ -> General). It's an option in the 'new project' wizard. Remove that and it'll revert back to a warning.




回答2:


The problem is the DwmEnableComposition function. Is deprecated as of Windows 8.

When the compiler encounters a deprecated symbol like in this case, it issues C4995.

More info:

DwmEnableComposition function

Compiler Warning (level 3) C4995




回答3:


I just confirmed this behavior in an existing project, in which I decided today to enable SDL checks in the unit test program for one of my C++ libraries. The function that flagged is one of my own that I marked as deprecated, but it has nothing to do with security, per se. So, I say that this begs the question; why is the compiler treating it as an error, when every other time I've used SDL checks that flagged such uses as swprintf, C4995 is a warning?



来源:https://stackoverflow.com/questions/28001687/warning-c4995-vs-error-c4995

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