[cppx] /W4, no warnings! (Disabling MSVC sillywarnings)

In order to compile at highest warning level (option /W4) with MSVC, its sillywarnings must be turned off lest you end up with not only an avalanche of compilation warnings but also compilation errors due to too many warnings!

The following compiler specific header suffices to compile code using e.g. <windows.h> without warnings, at highest warning level.

This list has been stable for a while, but the idea is to simply add whatever MSVC sillywarning one encounters:

In [progrock/cppx/compiler_specific/msvc/no_sillywarnings_please.h]:

#pragma warning( disable: 4061 )    // enum value is not *explicitly* handled in switch
#pragma warning( disable: 4099 )    // first seen using 'struct' now seen using 'class'
#pragma warning( disable: 4127 )    // conditional expression is constant
#pragma warning( disable: 4217 )    // member template isn't copy constructor
#pragma warning( disable: 4250 )    // inherits (implements) some member via dominance
#pragma warning( disable: 4251 )    // needs to have dll-interface to be used by clients
#pragma warning( disable: 4275 )    // exported class derived from non-exported class
#pragma warning( disable: 4347 )    // "behavior change", function called instead of template
#pragma warning( disable: 4355 )    // "'this': used in member initializer list
#pragma warning( disable: 4505 )    // unreferenced function has been removed
#pragma warning( disable: 4510 )    // default constructor could not be generated
#pragma warning( disable: 4511 )    // copy constructor could not be generated
#pragma warning( disable: 4512 )    // assignment operator could not be generated
#pragma warning( disable: 4513 )    // destructor could not be generated
#pragma warning( disable: 4623 )    // default constructor could not be generated
#pragma warning( disable: 4624 )    // destructor could not be generated
#pragma warning( disable: 4625 )    // copy constructor could not be generated
#pragma warning( disable: 4626 )    // assignment operator could not be generated
#pragma warning( disable: 4640 )    // a local static object is not thread-safe
#pragma warning( disable: 4661 )    // a member of the template class is not defined.
#pragma warning( disable: 4670 )    // a base class of an exception class is inaccessible for catch
#pragma warning( disable: 4672 )    // a base class of an exception class is ambiguous for catch
#pragma warning( disable: 4673 )    // a base class of an exception class is inaccessible for catch
#pragma warning( disable: 4675 )    // resolved overload was found by argument-dependent lookup
#pragma warning( disable: 4702 )    // unreachable code, e.g. in <list> header.
#pragma warning( disable: 4710 )    // call was not inlined
#pragma warning( disable: 4711 )    // call was inlined
#pragma warning( disable: 4820 )    // some padding was added
#pragma warning( disable: 4917 )    // a GUID can only be associated with a class, interface or namespace

 // The following are real warnings but are generated by almost all MS headers, including
 // standard library headers, so it's impractical to leave them on.
#pragma  warning( disable: 4619 )   // there is no warning number 'XXXX'
#pragma  warning( disable: 4668 )   // XXX is not defined as a preprocessor macro

A number of denizens of the Usenet group [comp.lang.c++] contributed to this list; thank you all!

In addition to the above the general abstracting header includes a portable general warning suppression functionality header, which as of this writing only defines …

In [progrock/cppx/devsupport/general_warnings_suppression.h]:

namespace progrock{ namespace cppx{ namespace devsupport {

    template< typename T >
    inline void suppressUnusedWarning( T const& ) {}

} } }  // namespace progrock::cppx::devsupport

It’s quite useful, in spite of doing absolutely nothing! 🙂

Advertisements

2 comments on “[cppx] /W4, no warnings! (Disabling MSVC sillywarnings)

  1. Pingback: cppx: /W4, no warnings, part II! (Disabling MSVC sillywarnings) | Alf on programming (mostly C++)

  2. Pingback: Warning Level per Header File « ASKLDJD

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s