Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Sparker0i opened this issue Mar 22, 2018 · 2 comments
Closed

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

Sparker0i opened this issue Mar 22, 2018 · 2 comments

Comments

@Sparker0i
Copy link

  • 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

@Sparker0i Sparker0i changed the title Namespace std has no member cin, cout Namespace std has no member cin, cout - Windows Mar 22, 2018
@bobbrow
Copy link
Member

bobbrow commented Mar 22, 2018

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
Copy link
Contributor

Closing this issue due to long inactivity.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants