Well after some tests I learned that my original prolog is best. Adding #define QT_CC_WARNINGS
#include <qglobal.h> actually lead to warnings as is inlcuding a lot more than i thought. But this warnins are swicth off only later in the file.
#include <qglobal.h> actually lead to warnings as is inlcuding a lot more than i thought. But this warnins are swicth off only later in the file.
There is not any benefit in my changes so i simplke removed them and all is well again.
just to let you know...
Regards,
Gunnar Roth
Gesendet: Montag, 09. März 2015 um 10:08 Uhr
Von: "Gunnar Roth" <gunnar.r...@gmx.de>
An: "development@qt-project.org" <development@qt-project.org>
Betreff: [Development] msvc warning policy in qt
Von: "Gunnar Roth" <gunnar.r...@gmx.de>
An: "development@qt-project.org" <development@qt-project.org>
Betreff: [Development] msvc warning policy in qt
Hello,
we have an in-house policy to use warning level 4 and warnings-as-errors with our projects.
The problem is that qt headers are generating warnings when using this level.
We switch off some silly warnings like "unreferenced inline function has been removed", which are just informal and cant be removed by us.
I created a Qt_prolog.h and an Qt_epilog.h which have to be included before and after every Qt Header.
prolog is this:
# pragma warning (push)
# pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
# pragma warning( disable : 4127 ) // conditional _expression_ is constant
# pragma warning( disable : 4510 ) // default constructor cannot be generated
# pragma warning( disable : 4512 ) // assignment operator could not be generated
# pragma warning( disable : 4244 ) // conversion from 'int/double/float/long' to 'qreal', possible loss of data
# pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
# pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
# pragma warning( disable : 4245 ) // 'initializing' : conversion from 'int' to 'unsigned short', signed/unsigned mismatch
# pragma warning( disable : 4251 ) // class 'QExplicitlySharedDataPointer<T>' needs to have dll-interface to be used by clients of class
# pragma warning( disable : 4231 ) // nonstandard extension used : 'extern' before template explicit instantiation
# pragma warning( disable : 4275 ) // non dll-interface class 'x' used as base for dll-interface class 'y'
# pragma warning( disable : 4995 ) // 'method' name was marked as #pragma deprecated
# pragma warning( disable : 4718 ) // recursive call has no side effects, deleting
# pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union
# pragma warning( disable : 4127 ) // conditional _expression_ is constant
# pragma warning( disable : 4510 ) // default constructor cannot be generated
# pragma warning( disable : 4512 ) // assignment operator could not be generated
# pragma warning( disable : 4244 ) // conversion from 'int/double/float/long' to 'qreal', possible loss of data
# pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class
# pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)
# pragma warning( disable : 4245 ) // 'initializing' : conversion from 'int' to 'unsigned short', signed/unsigned mismatch
# pragma warning( disable : 4251 ) // class 'QExplicitlySharedDataPointer<T>' needs to have dll-interface to be used by clients of class
# pragma warning( disable : 4231 ) // nonstandard extension used : 'extern' before template explicit instantiation
# pragma warning( disable : 4275 ) // non dll-interface class 'x' used as base for dll-interface class 'y'
# pragma warning( disable : 4995 ) // 'method' name was marked as #pragma deprecated
# pragma warning( disable : 4718 ) // recursive call has no side effects, deleting
epilog is just
# pragma warning (pop)
actually there are some warnings i would myself never switch off like "conversion from 'int/double/float/long' to 'qreal', possible loss of data" or 'initializing' : conversion from 'int' to 'unsigned short', signed/unsigned mismatch", but without that i get a warning ( and an error)#
now i found out that qglobal.h does disable warnings in its own globally, so it pollutes my warning level by that.
it even disables the imho very important warnings "assignment within conditional _expression_" and "C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc ".
Especially "assignment within conditional _expression_" is a live saver. you can easyly suppress it by writing if((a=open()) if the = is your real intent.
"C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc " is a strong idication you are using exceptions but in case of one thrown you are not unwinding stack getting memory leaks and other problems.
Luckily you can disable the warnings disabling, by defining QT_CC_WARNINGS
so i added
#define QT_CC_WARNINGS
#include <qglobal.h>
#include <qglobal.h>
after the # pragma warning (push) and added all warning disabling from qglobal.h to the end of the prolog file, whiuch are:
// copied from qglobale.h
# pragma warning(disable: 4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */
# pragma warning(disable: 4244) /* conversion from 'type1' to 'type2', possible loss of data */
# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
# pragma warning(disable: 4514) /* unreferenced inline function has been removed */
# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
# pragma warning(disable: 4706) /* assignment within conditional _expression_ */
# if _MSC_VER <= 1310 // MSVC 2003
# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */
# endif
# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
# if _MSC_VER < 1800 // MSVC 2013
# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */
# endif
# pragma warning(disable: 4710) /* function not inlined */
# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
# pragma warning(disable: 4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */
# pragma warning(disable: 4244) /* conversion from 'type1' to 'type2', possible loss of data */
# pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */
# pragma warning(disable: 4514) /* unreferenced inline function has been removed */
# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
# pragma warning(disable: 4706) /* assignment within conditional _expression_ */
# if _MSC_VER <= 1310 // MSVC 2003
# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */
# endif
# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
# if _MSC_VER < 1800 // MSVC 2013
# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */
# endif
# pragma warning(disable: 4710) /* function not inlined */
# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
additionally i found
include\QtCore\qfunctions_wince.h(224):#pragma warning(disable: 4273)
which disables the warning 'function' : inconsistent DLL linkage' Two definitions in a file differ in their use of dllimport.
so i added
#ifdef UNDER_CE
#include <qfunctions_wince.h>
#endif // UNDER_CE
#include <qfunctions_wince.h>
#endif // UNDER_CE
to my prolog after my #include <qglobal.h>
My problems are solved this way ,but i would rather like that qt takes care of this itself, meaning allowing setting warninglevel to 4 and warnings as errors and applications compile out of the box,
maybe by using my prolog/epilog approach.
Regards,
Gunnar Roth
_______________________________________________ Development mailing list Development@qt-project.org http://lists.qt-project.org/mailman/listinfo/development