【问题标题】:How to remove the C++ 11 extension warning in the vsCode如何删除 vsCode 中的 C++ 11 扩展警告
【发布时间】:2018-09-19 12:57:55
【问题描述】:

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

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

那么我怎样才能删除这个警告

【问题讨论】:

  • 使用 c++11 标志(或更高版本)?之前,我怀疑你真的想使用旧的auto
  • 您可以通过启用 C++11 来删除它。请查阅您的编译器和 VSCode 的文档以了解如何操作。

标签: c++ visual-studio-code vscode-settings


【解决方案1】:

您必须编辑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就会被支持。

【讨论】:

    猜你喜欢
    • 2018-12-05
    • 2020-12-19
    • 1970-01-01
    • 2021-07-11
    • 2016-08-26
    • 1970-01-01
    • 2017-09-30
    • 1970-01-01
    相关资源
    最近更新 更多