jtooker
jtooker

Reputation: 1243

How to use /std:c++latest with Qt 5.12

Prior to Qt 5.12, we had QMAKE_CXXFLAGS += /std:c++latest in our .pri file but after Qt 5.12 both c++latest and c++14 are being set as visual studio command line parameters in the generated .vcxproj project file.

I can get to C++17 via config += c++17, but then I get this error: Command line warning D9025: overriding '/std:c++latest' with '/std:c++17'.

How do I use the latest C++ standard in Visual Studio 2019 when using project files created by qmake? Said another way, how can I keep qmake from automatically inserting its own -std option?

Edit: I was wrong about c++14 automatically being applied. Another .pri file had set it.

Upvotes: 5

Views: 4704

Answers (3)

Ensai Tankado
Ensai Tankado

Reputation: 343

Just try this in your .pro file:

CONFIG += c++latest

Upvotes: 1

jtooker
jtooker

Reputation: 1243

Use CONFIG -= c++14 in the .pri (.pro) file in addition to QMAKE_CXXFLAGS += /std:c++latest to keep qmake from inserting its own /std compile flag.

Edit: this is only needed if a previously included .pri has CONFIG -= c++14 (and you cannot remove that from the other .pri)

Upvotes: 0

jobor
jobor

Reputation: 369

In Qt 5.13 you can work around the issue by adding

CONFIG += c++2a c++1z c++14

to your .pro file. The c++2a value maps to /std:c++latest.

Upvotes: 4

Related Questions