Is there an equivalent to -pedantic for gcc when using Microsoft's Visual C++ compiler?

試著忘記壹切 提交于 2019-12-10 02:44:44

问题


I would like to have my warnings set to the highest level using Microsoft Visual C++ compiler. Similar to using -pedantic on gcc. What compiler switches do you use to have the most warnings enabled?


回答1:


The highest warning level on Visual C++ is /Wall. The warning level can also be set numerically with /W0, /W1, ... /W4 to generate increasing levels of warnings.

The compiler will also check for 64 bit portability issues with /Wp64.

And you can tell it to treat warnings as errors with /WX

Visual C++ doesn't seem to have an real equivalent to -pedantic - which is asking gcc to report all warnings required to be reported by the ISO C and C++ standards.




回答2:


AS billmcc64 mentioned, gcc's -pedantic causes gcc to warn if you use any non-standard extensions. I don't think you can get MSVC to warn for a similar situation, but you can cause it to generate an error for these situations using the /Za option.




回答3:


Note that /Wp64 is not recommended by Microsoft as opposed to compiling directly for the 64-bit platform if possible.

Also note that the Team Developer edition has a /analyze option, which adds semantic checking for common code errors. You can also look at getting PC-lint from gimpel for additional semantic checking.




回答4:


if you want something like -pedantic, try a good lint like pc-lint (http://www.gimpel.com/html/products.htm).




回答5:


/W4 /Wall should do the trick.



来源:https://stackoverflow.com/questions/220298/is-there-an-equivalent-to-pedantic-for-gcc-when-using-microsofts-visual-c-co

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