<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>
<div>Well after some tests I learned that my original prolog is best. Adding <span style="font-family: Verdana; font-size: 12px; line-height: 19.2000007629395px;">#define QT_CC_WARNINGS</span><br style="font-family: Verdana; font-size: 12px; line-height: 19.2000007629395px;"/>
<span style="font-family: Verdana; font-size: 12px; line-height: 19.2000007629395px;">#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.</span></div>

<div><span style="font-family: Verdana; font-size: 12px; line-height: 19.2000007629395px;">There is not any benefit in my changes so i simplke removed them and all is well again.</span></div>

<div><span style="font-family: Verdana; font-size: 12px; line-height: 19.2000007629395px;">just to let you know...</span></div>

<div>Regards,</div>

<div>Gunnar Roth</div>

<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Montag, 09. März 2015 um 10:08 Uhr<br/>
<b>Von:</b> "Gunnar Roth" <gunnar.roth@gmx.de><br/>
<b>An:</b> "development@qt-project.org" <development@qt-project.org><br/>
<b>Betreff:</b> [Development] msvc warning policy in qt</div>

<div name="quoted-content">
<div style="font-family: Verdana;font-size: 12.0px;">
<div>Hello,</div>

<div>we have an in-house policy to use warning level 4 and warnings-as-errors with our projects.</div>

<div>The problem is that qt headers are generating warnings when using this level. </div>

<div>We switch off some silly warnings like  "unreferenced inline function has been removed", which are just informal and cant be removed by us.</div>

<div>I created a Qt_prolog.h and an Qt_epilog.h which have to be included before and after every Qt Header.</div>

<div> </div>

<div>prolog is this:</div>

<div>#  pragma warning (push)<br/>
#  pragma warning( disable : 4201 ) // nonstandard extension used : nameless struct/union    <br/>
#  pragma warning( disable : 4127 ) // conditional expression is constant<br/>
#  pragma warning( disable : 4510 ) // default constructor cannot be generated<br/>
#  pragma warning( disable : 4512 ) // assignment operator could not be generated<br/>
#  pragma warning( disable : 4244 ) // conversion from 'int/double/float/long' to 'qreal', possible loss of data<br/>
#  pragma warning( disable : 4251 ) // class needs to have dll-interface to be used by clients of class <br/>
#  pragma warning( disable : 4800 ) // 'BOOL' : forcing value to bool 'true' or 'false' (performance warning)<br/>
#  pragma warning( disable : 4245 ) //  'initializing' : conversion from 'int' to 'unsigned short', signed/unsigned mismatch<br/>
#  pragma warning( disable : 4251 ) //  class 'QExplicitlySharedDataPointer<T>' needs to have dll-interface to be used by clients of class<br/>
#  pragma warning( disable : 4231 ) //   nonstandard extension used : 'extern' before template explicit instantiation<br/>
#  pragma warning( disable : 4275 ) //  non dll-interface class 'x' used as base for dll-interface class 'y'<br/>
#  pragma warning( disable : 4995 ) //  'method' name was marked as #pragma deprecated<br/>
#  pragma warning( disable : 4718 ) //  recursive call has no side effects, deleting</div>

<div> </div>

<div> </div>

<div>epilog is just</div>

<div>#  pragma warning (pop)</div>

<div> </div>

<div> </div>

<div>actually there are some warnings i would myself never switch off like "<span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">conversion from 'int/double/float/long' to 'qreal', possible loss of data" or 'initializing' : conversion from 'int' to 'unsigned short', signed/unsigned mismatch", </span><span style="line-height: 19.2px;">but without that i get a warning ( and an error)#</span></div>

<div> </div>

<div><span style="line-height: 19.2px;">now i found out that qglobal.h does disable warnings in its own globally, so it pollutes my warning level by that.</span></div>

<div>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 ".</div>

<div>Especially <span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">"</span><span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">assignment within conditional expression" is a live saver. you can easyly suppress it by writing if((a=open())  if the = is your real intent.</span></div>

<div><span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">"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.</span></div>

<div> </div>

<div>Luckily you can disable the warnings disabling, by defining QT_CC_WARNINGS</div>

<div>so i added </div>

<div>#define QT_CC_WARNINGS<br/>
#include <qglobal.h></div>

<div> </div>

<div>after the <span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">#  pragma warning (push) and added all warning disabling from qglobal.h to the end of the prolog file, whiuch are:</span></div>

<div>// copied from qglobale.h<br/>
#    pragma warning(disable: 4251) /* class 'type' needs to have dll-interface to be used by clients of class 'type2' */<br/>
#    pragma warning(disable: 4244) /* conversion from 'type1' to 'type2', possible loss of data */<br/>
#    pragma warning(disable: 4275) /* non - DLL-interface classkey 'identifier' used as base for DLL-interface classkey 'identifier' */<br/>
#    pragma warning(disable: 4514) /* unreferenced inline function has been removed */<br/>
#    pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */<br/>
#    pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */<br/>
#    pragma warning(disable: 4706) /* assignment within conditional expression */<br/>
#    if _MSC_VER <= 1310 // MSVC 2003<br/>
#      pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */<br/>
#    endif<br/>
#    pragma warning(disable: 4355) /* 'this' : used in base member initializer list */<br/>
#    if _MSC_VER < 1800 // MSVC 2013<br/>
#      pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */<br/>
#    endif<br/>
#    pragma warning(disable: 4710) /* function not inlined */<br/>
#    pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */</div>

<div> </div>

<div>additionally <span style="line-height: 1.6em;">i found </span></div>

<div>include\QtCore\qfunctions_wince.h(224):#pragma warning(disable: 4273) </div>

<div> </div>

<div>which disables the warning <span style="font-family: "Segoe UI" , "Lucida Grande" , Verdana , Arial , Helvetica , sans-serif;line-height: 17.55px;">'function' : inconsistent DLL linkage'  </span><span style="color: rgb(42,42,42);line-height: 18.0px;font-family: "Segoe UI" , "Lucida Grande" , Verdana , Arial , Helvetica , sans-serif;">Two definitions in a file differ in their use of </span><a href="https://msdn.microsoft.com/en-us/library/3y1sfaz2.aspx" style="line-height: 18.0px;font-family: "Segoe UI" , "Lucida Grande" , Verdana , Arial , Helvetica , sans-serif;text-decoration: none;color: rgb(3,105,122);" target="_blank">dllimport</a><span style="color: rgb(42,42,42);line-height: 18.0px;font-family: "Segoe UI" , "Lucida Grande" , Verdana , Arial , Helvetica , sans-serif;">.</span></div>

<div> </div>

<div>so i added </div>

<div>#ifdef UNDER_CE<br/>
#include <qfunctions_wince.h><br/>
#endif // UNDER_CE</div>

<div> </div>

<div>to my prolog after my <span style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;">#include <qglobal.h></span></div>

<div> </div>

<div>
<div style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;"><span style="line-height: 19.2px;">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,</span></div>

<div style="font-family: Verdana;font-size: 12.0px;line-height: 19.2px;"><span style="line-height: 19.2px;">maybe by using  my prolog/epilog approach.</span></div>

<div> </div>

<div>Regards,</div>

<div>Gunnar Roth</div>

<div> </div>
</div>
</div>
_______________________________________________ Development mailing list Development@qt-project.org <a href="http://lists.qt-project.org/mailman/listinfo/development" target="_blank">http://lists.qt-project.org/mailman/listinfo/development</a></div>
</div>
</div></div></body></html>