c++c++11visual-studio-code

Why is visual studio code telling me that cout is not a member of std namespace?


I am trying to setup visual studio code to program in c++. I have already installed the extensions C/C++ and C/C++ Intellisense

Following is my code:

#include<iostream>
using namespace std;

int main()
{
 cout<< "hello" ;
}

The error I'm getting is identifier cout is undefined and when I write it as std::cout the error I get then is namespace std has no member cout . Following is my task.json file:

{
"version": "0.1.0",
"command": "make",
"isShellCommand": true,
"tasks": [
    {
        "taskName": "Makefile",
        // Make this the default build command.
        "isBuildCommand": true,
        // Show the output window only if unrecognized errors occur.
        "showOutput": "always",
        // No args
        "args": ["all"],
        // Use the standard less compilation problem matcher.
        "problemMatcher": {
            "owner": "cpp",
            "fileLocation": ["relative", "${workspaceRoot}"],
            "pattern": {
                "regexp": "^(.*):(\\d+):(\\d+):\\s+(warning|error):\\s+(.*)$",
                "file": 1,
                "line": 2,
                "column": 3,
                "severity": 4,
                "message": 5
            }
        }
    }
]
}

How do i fix this?


Solution

  • Its a bug.

    There is a workaround for this bug, go to File -> Preferences -> Settings in VS Code and change

    "C_Cpp.intelliSenseEngine": "Default" to "C_Cpp.intelliSenseEngine": "Tag Parser"