5

I am using VSCode and the code compiles just fine with the .run extension but the C/C++ extension is throwing me this error and underlining #include <iostream> as an error. And yes I have MinGW installed in my system.

Furthermore, I get the same error on visual studio community 2019, it does not execute there at all.

System: Windows 10 Version 10.0.19042 Build 19042

VSCode Version: 1.54.1

gcc version: 8.1.0

Visual Studio Community Version: 16.8.5 (Just used it to check if the problem was due to VSCode or if it was a systematic error)

Extension Showing the error: C/C++ for Visual Studio Code v1.2.2

The extension I use to run the code: Code Runner v0.11.3

UmiKami02
  • 77
  • 1
  • 5
  • Please update you question with your env. e.g. Windows, VSCode version, Extension and extension version, etc. – J'e Mar 11 '21 at 15:49
  • @J'e done! It sounds like a systematic error but beyond that, I have no idea of what is causing it. – UmiKami02 Mar 11 '21 at 16:04
  • 2
    Does this answer your question? [Visual Studio Code includePath](https://stackoverflow.com/questions/37522462/visual-studio-code-includepath) – J'e Mar 11 '21 at 16:20
  • Check if you have this path or similar: `C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include\iostream` Ctrl + Click in the iostream to open (if it exists) – testing_22 Mar 11 '21 at 16:25
  • You probably need to update the windows SDK in your visual studio community install. – drescherjm Mar 11 '21 at 16:30
  • ***And yes I have MinGW installed in my system.*** Which compiler are you using in VSCode. I expect each will have its own independent headers. – drescherjm Mar 11 '21 at 16:36
  • ***I have no idea of what is causing it*** Could be a misconfigured `c_cpp_properties.json` – drescherjm Mar 11 '21 at 16:37
  • Thanks, everyone! @J'e solution worked. I had to include the "include" directory from the MinGW folder. The error still jumps on previously created projects but it doesn't on new ones. – UmiKami02 Mar 11 '21 at 16:53
  • Update: It seems like it solved itself and idk how... Before I tried creating multiple files to see if it was a project dependant error. It was not, it was giving the same error in every new project. Now all of the sudden created a .cpp file manually and no errors jumped. So weird... – UmiKami02 Mar 11 '21 at 17:01
  • @drescherjm According to the c_cpp_properties.json the compiler is the MSVC compiler. – UmiKami02 Mar 11 '21 at 17:03

1 Answers1

7
  • hover on the line showing error
  • left click on the bulb, it will take you to C/C++ configurations
  • Now change complier path to C:/MinGW64/bin/g++.exe
  • on the top u will see a link c_cpp_properties.json click on it
  • in c_cpp_properties.json "intelliSenseMode": "windows-gcc-x64"

This works well.