5

I'm using Qt5 with Clang on Debian Jessie. To experiment with generic lambdas, in the .pro file there is:

CONFIG += c++14

And after building I got:

warning: 'auto' type specifier is a C++11 extension [-Wc++11-extensions]

To get rid of this obvious message I did:

QMAKE_CXXFLAGS += -Wc++11-extensions

But I keep getting the obvious message. Why? How to hide it?

2
  • Not duplicate. The other question is about how to enable C++14 in Qt Creator, which I do by CONFIG += c++14 (tested in Windows, works fine).
    – KcFnMi
    Commented May 1, 2016 at 2:55
  • Usually this warning would only be enabled if you were in pre-c++11 mode so I suspect that your CONFIG option is actually not working
    – M.M
    Commented May 1, 2016 at 2:57

2 Answers 2

13

According to qmake's repository history, the CONFIG += c++14 stanza was added in qmake version 5.4: https://codereview.qt-project.org/#/c/87831/

However, it seems Debian Jessie only has qmake version 5.3 (https://packages.debian.org/jessie/qt5-qmake)

As a workaround, you can use

QMAKE_CXXFLAGS += -std=c++14

or

QMAKE_CXXFLAGS += -std=gnu++14
2
  • QMAKE_CXXFLAGS += -std=c++1y also works here (in Jessie). You went directly to the point. Interestingly, on Windows, where I'm using CONFIG += c++14 it cannot be replaced by any of the "alternative" stanza
    – KcFnMi
    Commented May 1, 2016 at 3:12
  • @KcFnMi Right, those are actual compiler flags for GCC or clang. For other compilers like MSVC, you'd need something else. Commented Nov 10, 2019 at 0:53
9

you want QMAKE_CXXFLAGS+=-Wno-c++11-extensions I suspect.

clang compiler documentation

pertinent part:

-Wfoo: Enable warning foo.

-Wno-foo: Disable warning foo.

4
  • Do you have a reference for your answer? I see no effect here.
    – KcFnMi
    Commented May 1, 2016 at 2:50
  • I do not, just in my experience you need to put 'no' in to suppress a warning
    – Jfevold
    Commented May 1, 2016 at 2:51
  • 1
    Yout forgot the -, -Wno-c++11-extensions does it.
    – KcFnMi
    Commented May 1, 2016 at 3:00
  • please accept my answer if it did what you want. If you'd like to see improvements to my answer, or more documentation, please let me know what specifically you find lacking.
    – Jfevold
    Commented May 1, 2016 at 3:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.