Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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.

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.

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

/W4 /Wall should do the trick.

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