下面是我的远程服务器和本地vscode
这遵循上下文
"configurations": [
{
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"/usr/include"
],
"defines": [],
"compilerPath": "/usr/bin/clang++-12",
"cStandard": "gnu11",
"cppStandard": "c++17",
"intelliSenseMode": "linux-clang-x64",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
}
在.vscode文件夹下的远程c_cpp_properties.json中
settings.json:
"C_Cpp.default.cppStandard": "c++17",
"clang.cxxflags": [
"-std=c++17"
],
但是我的代码可以编译
这个问题是因为cmake工具插件,在远程服务器中找到您的compile_commands.json
文件,然后编辑以添加选项-std=c++17
;因此,改变例如
"command": "/usr/bin/clang++-12 -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c /home/source/main.cpp",
至
"command": "/usr/bin/clang++-12 -g -o CMakeFiles/linuxCode.dir/main.cpp.o -c -std=c++17 /home/source/main.cpp",