Home Help Center

compiler warnings c4251

gordonproctorgordonproctor Member Gordon ProctorOrganization: Tullett PrebonProject: Price discovery for an inter dealer broker
Our compiler is visual studio 2013 and we develop in c++.
Our policy is to compile with warning level 4 and to treat warnings as errors.
The result of this is that the compile fails with hundreds C4251 warnings such as
1>C:\Program Files (x86)\ZeroC\Ice-3.5.1\include\IceUtil/Exception.h(43): warning C4251: 'IceUtil::Exception::_stackTrace' : class 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' needs to have dll-interface to be used by clients of class 'IceUtil::Exception'

This happens in the example projects as well.

So my question is, can I compile an ICE project without warnings when set to level 4 warnings?
There doesn't seem to be a way to switch this warning off at the project level.

I'm very opposed to changing current projects that are to use ICE to warning level 3, since they compile warning free at level 4 without ICE.

Comments

  • xdmxdm La Coruña, SpainAdministrators, ZeroC Staff Jose Gutierrez de la ConchaOrganization: ZeroC, Inc.Project: Ice Developer ZeroC Staff
    To build with W4 your only option is to disable the relevant warnings, you can do that in IceUtil/Config.h

    replace:
    #ifdef _MSC_VER
    //
    // Move some warnings to level 4
    //
    #   pragma warning( 4 : 4250 ) // ... : inherits ... via dominance
    #   pragma warning( 4 : 4251 ) // class ... needs to have dll-interface to be used by clients of class ..
    #endif
    

    With
    #ifdef _MSC_VER
    //
    // Disable some warnings
    //
    #   pragma warning( disable : 4127 ) // conditional expression is constant
    #   pragma warning( disable : 4250 ) // ... : inherits ... via dominance
    #   pragma warning( disable : 4251 ) // class ... needs to have dll-interface to be used by clients of class ..
    #   pragma warning( disable : 4512 ) // class ... assignment operator could not be generated
    #endif
    

    I was able to build hello demo with W4 by doing this change. Be aware that this will disable these warnings for any files that include Ice header or Ice generated code.
  • gordonproctorgordonproctor Member Gordon ProctorOrganization: Tullett PrebonProject: Price discovery for an inter dealer broker
    Thank you, that worked for me.
Sign In or Register to comment.