Please nominate your Qt Champions for 2021!

Large number of QT warnings when using a precompiled headers approach

  • I have recently switched a project to making use of precompiled headers due to compilation becoming slow. Before doing so, it built without any significant warnings.

    However, after adding all the QT headers I use in my project (of which I use 40-50) to the stdafx.h file, during building of the solution, when the stdafx file gets built I receive a huge number (1000's) of warning relating to QT functions. In particular, I get a lot of "Warning C4251" e.g.

    1>c:\Qt\5.9\msvc2015_64\include\QtGui/qrawfont.h(154): warning C4251: 'QRawFont::d': class 'QExplicitlySharedDataPointer<QRawFontPrivate>' needs to have dll-interface to be used by clients of class 'QRawFont' (compiling source file TitleBar.cpp)

    The other two common warning types (albeit far less) are c4800 and c4244.

    I am using QT 5.9 64-bit, on a Windows 10 box running VS2015,.

    I can obviously just disable them, but I don't really like to do such a thing without understanding why this is happening.

Log in to reply