lazysheep
lazysheep

Reputation: 113

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

When i use the auto type, there just have a warning in my vscode

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

So how can i remove this warning

Upvotes: 3

Views: 6656

Answers (1)

P.W
P.W

Reputation: 26800

You will have to edit the c_cpp_properties.json file. See an example of it 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
}

In that file an option cppStandard is listed. It has to be set to c++11. Then auto will be supported.

Upvotes: 4

Related Questions