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?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With