如何删除 vsCode 中的 C++ 11 扩展警告

How to remove the C++ 11 extension warning in the vsCode

本文关键字:C++ 中的 扩展 警告 vsCode 何删除 删除      更新时间:2023-10-16

当我使用auto类型时,我的 vscode 中只有一个警告

'auto' type specifier is a C++11 extension [-Wc++11-extensions] (14, 10)

那么我该如何删除此警告

您必须编辑c_cpp_properties.json文件。在此处查看示例。

{
"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将得到支持。