Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt 5: CONFIG+=c++11 vs QMAKE_CXXFLAGS+=-std=c++11 (What's better)

Tags:

c++

std

c++11

qt

qt5

I know that if you want to add C++11 features to your Qt code you need to write this line in your .pro file:

QMAKE_CXXFLAGS += -std=c++11, 

but also you can use instead of it this another line:

CONFIG+=c++11.

The question is: What's better to use?

like image 696
Carlos Duarte Avatar asked Jan 10 '23 07:01

Carlos Duarte


1 Answers

CONFIG+=c++11 is better because it is handled by qmake tool which knows how to set it properly while QMAKE_CXXFLAGS += -std=c++11 almost directly says to qmake to set -std=c++11 flag to a compiler but it may not work because somewhere it is -std=gnu++11 or even -std=c++0x so you may have a compiler error. So it is not only about having an error but about portability too.

From the qt5-qmake documentation:

CONFIG

Specifies project configuration and compiler options. The values are recognized internally by qmake and have special meaning.

like image 140
Victor Polevoy Avatar answered Jan 11 '23 20:01

Victor Polevoy