Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove the C++ 11 extension warning in the vsCode [duplicate]

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

like image 699
lazysheep Avatar asked Nov 03 '25 18:11

lazysheep


1 Answers

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.

like image 90
P.W Avatar answered Nov 05 '25 10:11

P.W



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!