1

How can I disable C++11/14 in Qt Creator?

I'd like to compile my project as C++98/03 code. By default it ran gcc like this:

g++ ... -std=gnu++11 -Wextra ... 

I edited *.pro file so it contains the following:

...
CONFIG -= c++11
CONFIG += no-c++11 no-c++14
QMAKE_CXXFLAGS += -std=c++98 -pedantic
...

The compiler string has become this:

g++ ... -std=c++98 -pedantic -g -std=gnu++11 ...

It is still compiling as C++11. How can I switch off C++11 support?

Compiler: mingw 5.3.0
Qt: 5.9.0 QtCreator: 4.4.1

Thanks for any help!

Agi Hammerthief
  • 2,114
  • 1
  • 22
  • 38
Konstantin T.
  • 994
  • 8
  • 22
  • 1
    See [this answer](https://stackoverflow.com/a/42724650/3484570). Try adding `QMAKE_CXXFLAGS_GNUCXX11 = -std=c++98` to the `.pro` file. – nwp Jan 26 '18 at 14:27
  • @tobi303 sinсe 5 version of mingw c++11 is used by default, so you don't need add any flag to enable it, so I wondered how to disable it now :) – Konstantin T. Jan 26 '18 at 14:29
  • yeah actually i have to admit that i didnt read the question carefully enough and the dupe doesnt help at all – 463035818_is_not_an_ai Jan 26 '18 at 14:31
  • 1
    @nwp seems it helps. Thank you! – Konstantin T. Jan 26 '18 at 14:35
  • 1
    Notice that newer versions of Qt require c++11 IIRC. – SteakOverflow Jan 26 '18 at 14:45
  • @SteakOverflow yes, it's ok for me. – Konstantin T. Jan 26 '18 at 15:05
  • The Qt framework definitely requires C++11 for version 5.9, but the actual project code that links to it - not necessarily. – dtech Jan 26 '18 at 15:16
  • 1
    @dtech headers won't compile. and c++11 is required for all 5.x and very recommended for 4.8.6. Not to mention that all 4.x are not quite compatible with c++98, they rely on c++0x. c++98 is very old standard, too old to use safely on consumer hardware. Just to say when we tried that for some 4,8,6, it ended with horrible memory leaking. – Swift - Friday Pie Jan 27 '18 at 16:41
  • Possible duplicate of [How to set qmake to C++14 with recent MinGW?](https://stackoverflow.com/questions/42719326/how-to-set-qmake-to-c14-with-recent-mingw) – Ruslan Jun 20 '18 at 08:00

0 Answers0