VS Code Setup Issues
This page has the fixes for common issues with VSCode. If everything is working fine for you, you get to ignore it!
Include errors detected
Symptom:
The very first include in your file looks like this:
Here I made that error by intentionally misspelling "iostream". You would get that same error message for the correct spelling.
Cause:
VSCode is looking for the wrong compiler when trying to provide Intellisense help. (Intellisense is Microsoft's name for on-the-fly code checking.)
This could be because you did not install the compiler correctly, or because you have multiple compilers available. (This might be true if you installed other development tools before taking this class or since your initial setup.)
To figure out which it is, try running g++
from the command prompt.
If that works, then you probably have multiple compilers. If that does not work, your compiler
is not properly set up.
Fix:
If your compiler is not set up correctly (g++ does not work
),
go fix the compiler setup.
(Is it properly listed on the PATH?) Then restart VSCode to test the fixed setup.
If g++
works, Intellisense is finding the wrong compiler. To fix that, open the command
palette (View -> Command Palette) then find C/C++ Select Intellisense Configuration
Then select g++:
If you do not see g++, your compiler is NOT set up correctly. If, like me, you see a bunch of options, you have multiple compilers available (and that is why Intellisense is confused).
Once you select g++, the error in this project should go away.
You will have to either redo the Intellisense Configuration in each project or copy the
setting from this project to your global settings. To copy it to your global settings,
first open the file settings.json
from inside the .vscode
folder in your project.
Then find the line like the one below that sets the compilerPath:
"C_Cpp.default.compilerPath": "C:\\MinGW2\\mingw64\\bin\\g++.exe",
Copy that line of text. Then open your global settings by going to the Command Palette and finding Preferences: Open User Settings (JSON):
Then past the line you copied right before the }
. The line before it must end in a comma
(add one if it is not there.) The result should look like:
"SOME OTHER LINE":"SOME OTHER VALUE",
"C_Cpp.default.compilerPath": "C:\\MinGW2\\mingw64\\bin\\g++.exe",
}