Can't use c++17 features using g++ 7.2 in QtCreator

后端 未结 3 1923
既然无缘
既然无缘 2020-12-16 10:36

I have recently updated gcc and g++ to version 7.2. I would like to try out std::experimental::any and std::variant in particular, and I am using Q

3条回答
  •  天命终不由人
    2020-12-16 11:26

    Edit 3/2019: You can use CONFIG += c++17 since Qt 5.12.


    The actual flag is c++1z, not c++17. In short, to get C++17 support, you don't need to modify QMAKE_CXXFLAGS and can instead simply use CONFIG += c++1z.

    Discussion on the reason why can be found in this bug report, but it pretty much amounts to "we implemented it as c++1z before C++17 was standardized, and now we won't bother aliasing it."

    Note: I realize you just needed a clean and rebuild. I'm answering the underlying question of "what flags do I need to use to enable C++17 support?"

提交回复
热议问题