Vscode-cpptools: Namespace std has no member cin, cout - Windows

Created on 22 Mar 2018  Â·  2Comments  Â·  Source: microsoft/vscode-cpptools

  • 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

Language Service question

Most helpful comment

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.

All 2 comments

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.

Closing this issue due to long inactivity.

Was this page helpful?
0 / 5 - 0 ratings