Disable visual studio warnings



  • We treat warnings as bugs and our policy is that our own code has to build cleanly, so I need to be able to spot warnings about my code. When I build our qt based project in visual studio 2010 I get literally 10s of thousands of warnings about Qt's code. This is fine, I just need a way to disable them. Wrapping all of our include of qt headers with specific pragmas is not desirable. Any one know how to globably tun of warnings for just qt headers??

    sample:
    @
    299>c:\qt\4.8.4\include\qtcore../../src/corelib/tools/qlist.h(409): warning C4127: conditional expression is constant
    299>c:\qt\4.8.4\include\qtcore../../src/corelib/tools/qlist.h(430): warning C4127: conditional expression is constant
    299> c:\qt\4.8.4\include\qtcore../../src/corelib/tools/qlist.h(429) : while compiling class template member function 'void QList<T>::node_destruct(QList<T>::Node *,QList<T>::Node *)'
    299> with
    299> [
    299> T=QList<QVariant>
    299> ]
    299> c:\qt\4.8.4\include\qtcore../../src/corelib/tools/qlist.h(707) : while compiling class template member function 'void QList<T>::detach_helper(int)'
    299> with
    299> [
    299> T=QList<QVariant>
    299> ]
    299> c:\qt\4.8.4\include\qtcore../../src/corelib/tools/qlist.h(730) : while compiling class template member function 'QList<T>::~QList(void)'
    299> with
    299> [
    299> T=QList<QVariant>
    299> ]
    299> c:\qt\4.8.4\include\qtcore../../src/corelib/kernel/qmetatype.h(196) : see reference to function template instantiation 'void *qMetaTypeConstructHelper<T>(const T *)' being compiled
    299> with
    299> [
    299> T=QList<QList<QVariant>>
    299> ]
    299> c:\users\burlen\paraview\next\paraview\qt\core\pqSMAdaptor.h(47) : see reference to function template instantiation 'int qRegisterMetaType<QList<T>>(const char *,QList<T> *)' being compiled
    299> with
    299> [
    299> T=QList<QVariant>
    299> ]
    @

    [code wrappings added "see":http://qt-project.org/wiki/ForumHelp#e3f82045ad0f480d3fb9e0ac2d58fb01 , koahnig]


  • Moderators

    welcome to devnet

    you can use the a pragma for disabling and enabling warnings.
    @
    #ifdef _MSC_VER
    #pragma warning ( disable : 4127 )
    #endif
    @

    You can also use "enable" to switch on the warnings.

    The "problem" is to locate the headers and embracing them with these pragmas.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.