如何删除 vsCode 中的 C++ 11 扩展警告
How to remove the C++ 11 extension warning in the vsCode
当我使用 auto
类型时,我的 vscode
中只有一个警告
'auto' type specifier is a C++11 extension [-Wc++11-extensions] (14, 10)
那么我怎样才能删除这个警告
您必须编辑 c_cpp_properties.json
文件。看一个例子 here.
{
"env": {
"myDefaultIncludePath": ["${workspaceFolder}", "${workspaceFolder}/include"],
"myCompilerPath": "/usr/local/bin/gcc-7"
},
"configurations": [
{
"name": "Mac",
"intelliSenseMode": "clang-x64",
"includePath": ["${myDefaultIncludePath}", "/another/path"],
"macFrameworkPath": ["/System/Library/Frameworks"],
"defines": ["FOO", "BAR=100"],
"forcedInclude": ["${workspaceFolder}/include/config.h"],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "/path/to/compile_commands.json",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
在该文件中列出了一个选项 cppStandard
。它必须设置为 c++11
。那么auto
就支持了。
当我使用 auto
类型时,我的 vscode
'auto' type specifier is a C++11 extension [-Wc++11-extensions] (14, 10)
那么我怎样才能删除这个警告
您必须编辑 c_cpp_properties.json
文件。看一个例子 here.
{
"env": {
"myDefaultIncludePath": ["${workspaceFolder}", "${workspaceFolder}/include"],
"myCompilerPath": "/usr/local/bin/gcc-7"
},
"configurations": [
{
"name": "Mac",
"intelliSenseMode": "clang-x64",
"includePath": ["${myDefaultIncludePath}", "/another/path"],
"macFrameworkPath": ["/System/Library/Frameworks"],
"defines": ["FOO", "BAR=100"],
"forcedInclude": ["${workspaceFolder}/include/config.h"],
"compilerPath": "/usr/bin/clang",
"cStandard": "c11",
"cppStandard": "c++17",
"compileCommands": "/path/to/compile_commands.json",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
在该文件中列出了一个选项 cppStandard
。它必须设置为 c++11
。那么auto
就支持了。