Search code examples
c++qtmingwqmakec++14

enable c++1y in qt (mingw)


I'm trying ton enable CONFIG += c++14 in qmake (using mingw), but I always get -std=c++0x in the makefiles generated. the only workaround I found is to add in my .pro file QT_GCC_MAJOR_VERSION = 4 and QT_GCC_MINOR_VERSION = 9, then I get properly -std=c++1y. Those variables should be set automatically according to the compiler used, am I right ? What could make these variables not being set ?

The most simple pro file i can imagine also have this problem:

TARGET = testProj

TEMPLATE = app

CONFIG += c++14

SOURCES += main.cpp

Solution

  • This is in fact a Qt bug which affects mingw : https://bugreports.qt.io/browse/QTBUG-44142

    An easy workaround is to edit the file mkspecs\features\c++14.prf and comment out the line greaterThan(QT_GCC_MAJOR_VERSION, 4)|greaterThan(QT_GCC_MINOR_VERSION, 7): \