如题,我下载的一个Qt5为何不支持C++11新标准,就连其中最简单的Lambda表达式都不支持。官网上说的原话是:Additionally, if your compiler supports C++11 lambdas, you can even connect directly to a lambda function.
请问谁的Qt支持C++11,能告诉我怎么做的吗?
...全文
13014打赏收藏
为何Qt5不支持C++11
如题,我下载的一个Qt5为何不支持C++11新标准,就连其中最简单的Lambda表达式都不支持。官网上说的原话是:Additionally, if your compiler supports C++11 lambdas, you can even connect directly to a lambda function. 请问谁的Qt支持C++11,能告诉我怎么做的吗?
http://woboq.com/blog/cpp11-in-qt5.html
MSVC does not require any special flags and enables the C++11 features by default, but GCC or Clang require -std=c++0x.
By default, Qt5 itself will be compiled with the C++11 flags on compilers that need it.
If you use qmake, you can add that line to your .pro file (Qt5):
CONFIG += c++11
(In Qt4, it should be something like: gcc:CXXFLAGS += -std=c++0x)
And now you can enjoy all the nice features of C++11. (It is already worth doing it only for being able to use auto)
Update: Also check out the changes in C++14