【发布时间】:2019-03-08 04:30:55
【问题描述】:
使用“-Xclang -std=c++17”我可以构建可执行文件,但是我找不到激活 c++17 智能感知的内容。我已经尝试了很多组合,如下所示,但似乎都不起作用
CMakeLists.txt
cmake_minimum_required(VERSION 3.9.2)
set(CMAKE_CXX_STANDARD 17)
project(myapp)
add_compile_options("-Xclang" "-std=c++17")
add_executable(myapp main.cpp)
set_target_properties(myapp PROPERTIES CXX_STANDARD 17)
target_compile_features(myapp PRIVATE cxx_std_17)
main.cpp
#include <tuple>
namespace test1::test2 // red [qualified name is not allowed]
// ^^^^^^^^^^^^^
{}
int main()
{
auto[a, b] = std::pair<int, int>();
// ^^^^^^
return 0;
}
CMakeSettings.json
{
// See https://go.microsoft.com//fwlink//?linkid=834763 for more information about this file.
"configurations": [
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"inheritEnvironments": [ "msvc_x64_x64" ],
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"variables": [
{
"name": "CMAKE_CXX_COMPILER",
"value": "clang-cl"
},
{
"name": "CMAKE_C_COMPILER",
"value": "clang-cl"
},
{
"name": "CMAKE_SYSTEM_NAME",
"value": "Windows"
}
]
}
]
}
【问题讨论】:
标签: c++ cmake visual-studio-2017