How can I use C++14 features when building qmake projects?

This is now supported properly from Qt 5.4. You just type this into your qmake project file:

CONFIG += c++14

The necessary code change went in the middle of 2014 by Thiago:

Add support for CONFIG += c++14

I have just created the necessary documentation change:

Mention the c++14 CONFIG option in the qmake variable reference

Please note that variable templates are only supported from gcc 5.0, but then your code works just fine. This can be used for testing C++14 with older gcc:

main.cpp

#include <iostream>

int main()
{
    // Binary literals: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf
    // Single-quotation-mark as a digit separator: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
    std::cout << 0b0001'0000'0001;
    return 0;
}

main.pro

TEMPLATE = app
TARGET = main
CONFIG -= qt
CONFIG += c++14
SOURCES += main.cpp

Build and Run

qmake && make && ./main

Output

257

Leave a Comment