/Za compiler directive does not compile system headers in VS2010

青春壹個敷衍的年華 提交于 2019-12-29 01:36:36

问题


I wanted to disable language extensions to be able to do some tests in my project. I found that I must set /Za compiler directive from http://msdn.microsoft.com/en-us/library/0k0w269d.aspx, but after this I have errors if I include windows headers. Is there a way to write standard compliant code(enforced by the compiler, not by other programmers/code reviews) in VS2010 and still use system headers?

Thanks you!


回答1:


The windows headers have never compiled with /Za.

There are other problems as well with /Za, that has caused Microsoft to stop testing their C++ standard library with that option. As told here:

http://permalink.gmane.org/gmane.comp.lib.boost.devel/212180

The recommendation is not to use it in "real" code.




回答2:


Isolate your use of <windows.h> into a source file(s) that you don't compile with /Za and use the parameter on the other files.



来源:https://stackoverflow.com/questions/5489326/za-compiler-directive-does-not-compile-system-headers-in-vs2010

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