Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 210
KPexEA Avatar asked Oct 20 '08 23:10

KPexEA


2 Answers

Checkout the new /permissive- option which is supported in Visual Studio 2017 and later. The /permissive- option is compatible with almost all of the header files from the latest Windows Kits, such as the Software Development Kit (SDK) or Windows Driver Kit (WDK), starting in the Windows Fall Creators SDK (10.0.16299.0). Older versions of the SDK may fail to compile under /permissive- for various source code conformance reasons.

There is also the /Za option for disabling all the language extensions, but this also causes compilation errors when header files from the Windows Kits are used (such as winnt.h and winioctl.h). So, this option is not really viable.

See: https://docs.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance

like image 116
boqpoq Avatar answered Sep 19 '22 08:09

boqpoq


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.

like image 40
billmcc Avatar answered Sep 20 '22 08:09

billmcc