How can I use C++14 features when building qmake projects?

后端 未结 4 1737
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-01 18:16

I\'m currently using C++11 features in my Qt applications. However, I\'d like to use some of the new C++14 features in my applications.

To enable C++11 in a Qt appli

4条回答
  •  [愿得一人]
    2020-12-01 18:47

    For some weird reason this is what Qt does: If the compiler is gcc or mingw, CONFIG+=C++14 is transformed to a compiler flag -std=c++14 (that what you expect)

    If it's another compiler (like clang), CONFIG=C++14 is stupidly transformed to -std=c++11 (sic!), so you will get errors about unsupported features, even if your clang version correctly supports C++14.

    To fix it, specify the flag explicitly:

    QMAKE_CXXFLAGS += -std=c++14
    

    This way, you're sure that your compiler (g++, mingw or clang) will receive the correct flags.

提交回复
热议问题