Skip to content

Namespace std has no member cin, cout - Windows #1724

Closed
@Sparker0i

Description

@Sparker0i
  • Operating System and version: Windows 10 x64, 16299
  • VS Code version : 1.21.1
  • C/C++ extension version: 0.15.0
  • Other extensions: No

I'm writing a simple C++ code:

#include <iostream>

int get_change(int m) {
  int n;
  //write your code here
  return n;
}

int main() {
  int m;
  std::cin >> m;
  std::cout << get_change(m) << '\n';
}

Here is my c_cpp_properties.json :

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceRoot}",
                "C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/include",
                "C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/include-fixed",
                "C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/include",
                "C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++",
                "C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32",
                "C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/backward",
                "C:/tools/mingw64/lib/gcc/x86_64-w64-mingw32/5.3.0/include",
                "C:/tools/mingw64/include",
                "C:/tools/mingw64/lib/gcc/x86_64-w64-mingw32/5.3.0/include-fixed"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE"
            ],
            "intelliSenseMode": "msvc-x64",
            "browse": {
                "path": [
                    "${workspaceRoot}",
                    "C:/tools/mingw64/lib/gcc/x86_64-w64-mingw32/5.3.0/include",
                    "C:/tools/mingw64/lib/gcc/x86_64-w64-mingw32/5.3.0/include-fixed",
                    "C:/tools/mingw64/include/*"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            }
        }
    ],
    "version": 3
}

Here is the output I get by running g++ -Wp,-v -E -xc -x c++ - :

 C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/include
 C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/include-fixed
 C:/tools/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/5.3.0/../../../../x86_64-w64-mingw32/include
 C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++
 C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/x86_64-w64-mingw32
 C:/tools/mingw64/lib/gcc/../../x86_64-w64-mingw32/include/c++/backward

(which I have included in the include Path)

After including these locations, the green line under #include <iostream> is gone, but now I get 2 new errors:

namespace "std" has no member "cin" (11,8)
namespace "std" has no member "cout" (12,8)

PS. Also to note that I installed MinGW using choco package manager

Activity

changed the title [-]Namespace std has no member cin, cout[/-] [+]Namespace std has no member cin, cout - Windows[/+] on Mar 22, 2018
bobbrow

bobbrow commented on Mar 22, 2018

@bobbrow
Member

Using this document as a reference, I see two problems with that config:

  • intellisenseMode should be clang-x64
  • A few defines are missing. Copy in the missing ones from the document linked above.
michelleangela

michelleangela commented on Aug 21, 2019

@michelleangela
Contributor

Closing this issue due to long inactivity.

locked and limited conversation to collaborators on Oct 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @bobbrow@Sparker0i@michelleangela

        Issue actions

          Namespace std has no member cin, cout - Windows · Issue #1724 · microsoft/vscode-cpptools