How to enable C++11 in CLion?

前端 未结 2 770
旧巷少年郎
旧巷少年郎 2020-11-29 09:09

I\'m trying to run C++11 code in CLion but it doesn\'t work. It says:

...
    /projects/CLion/untitled/main.cpp:7:1: note: C++11 ‘constexpr’ only available w         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 09:59

    I tried to set CMAKE_C_FLAGS

    According to the documentation the CMAKE_C_FLAGS set C language flags for all build types. For C++ you need use CMAKE_CXX_FLAGS instead:

    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
    

提交回复
热议问题