Description
Hello, so I am new to coding and wanted to use VS Code to code in C++, so I installed it, installed C/C++ IntelliSense v0.12.4 and followed instructions on the VS Code website to make a c_cpp_properties.json file and copied the code into it like they said. When I open my .cpp project that I had made in notepad++, I get the error:
"#include errors detected. Please update your includePath. IntelliSense features for this translation unit (directory\file.cpp) will be provided by the Tag Parser. (9, 1)
cannot open source file "iostream" (9, 1)"
My .cpp code
`#include
using namespace std;
int main()
{
string firstName, lastName;
double hourRate, numHours;
cout << "+----------------------------------------+" << endl;
cout << " Your first name and last name: ";
cin >> firstName >> lastName;
cout << " Your hourly rate: ";
cin >> hourRate;
cout << " Number of hours worked last week: ";
cin >> numHours;
cout << endl;
double regPay, overTPay, gPay, socSec, med, netPay;
if (numHours <= 40)
{
regPay = hourRate * numHours;
gPay = regPay;
overTPay = 0;
}
else
{
double oTHours;
oTHours = numHours - 40;
regPay = hourRate * (numHours - (numHours - 40));
overTPay = (hourRate * 1.5) * oTHours;
gPay = regPay + overTPay;
}
socSec = gPay * 0.062;
med = gPay * 0.0145;
netPay = gPay - (socSec + med);
cout << "+----------------------------------------+" << endl << endl;
cout << " Pay Stub\n" << " Regular pay $" << regPay << endl;
cout << " Overtime pay $" << overTPay << endl;
cout << " Gross pay $" << gPay << endl;
cout << " Social Sec. $" << socSec << endl;
cout << " Medicare $" << med << endl;
cout << " Net Pay $" << netPay << endl << endl;
cout << "+----------------------------------------+" << endl << endl;
cout << " Pay to: " << firstName << " " << lastName << endl;
cout << " Total Pay: $" << netPay << endl << "\t\t\t ";
cout << "Signed: P inc." << endl;
cout << "+----------------------------------------+" << endl;
return 0;
}`
My c_cpp_properties.json file
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"${workspaceRoot}",
"C:/MinGW/lib/gcc/mingw32/6.3.0/include/c++",
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 3
}
Also, when I hover over the "" this shows up:
"#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:\Stuff\CS11-Things\Homeworks\A3\paycheck.cpp) will be provided by the Tag Parser.
cannot open source file "iostream""
Let me know if you need any more information
Activity
sean-mcmanus commentedon Sep 18, 2017
Your includePath only has
${workspaceRoot}
. You need to add the path to your system directories. If you're using MinGW, see https://github.com/Microsoft/vscode-cpptools/blob/master/Documentation/LanguageServer/MinGW.md .GiBg1aN commentedon Sep 19, 2017
If you are using Linux you have to add the path
/usr/include/linux
ZoeVonFeng commentedon Sep 20, 2017
I had same issue on windows, after I add the
"C:\\cygwin64\\lib\\gcc\\x86_64-pc-cygwin\\6.4.0\\include\\c++"
at includePath, I got this error:cannot open source file "bits/c++config.h" (dependency of "iostream")
bobbrow commentedon Sep 20, 2017
What does gcc tell you the include path should be? Run this command and make sure all of the paths printed out are listed in your c_cpp_properties.json:
gcc -v -E -x c++ -
NikoGP commentedon Sep 20, 2017
@sean-mcmanus after adding the code from the link you gave it still complains, I didn't add "C_Cpp.intelliSenseEngine": "Default" to my settings.json file because I have no clue where it is. Anyway, this is the new error I am getting.
"#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:\\program.cpp) will be provided by the Tag Parser. (9, 1) cannot open source file "iostream" (9, 1)"
sean-mcmanus commentedon Sep 20, 2017
@NikoGP Go to File->Preferences->Settings and search for "intelliSenseEngine" to find the setting. You have "Default" set already though. Did you run the gcc command @bobbrow mentioned? Can you provide your updated c_cpp_properties.json? You basically need to find where your iostream header is getting pulled from by your compiler and add the path to the includePath setting (and make sure the defines are correct). Does Go to Definition work on the header file? If so, that means the iostream file was found via a recursive search of your browse.path setting.
NikoGP commentedon Sep 20, 2017
Here is my current c_cpp_properties.json file, when I hover over the "{" before configurations Win32 it says "missing property "name""
Also, I installed cygwin before installing MingW, I'm not sure if that messes anything up or not
bobbrow commentedon Sep 20, 2017
I reformatted your comment. There is a "configurations" element inside your "configurations" which is invalid syntax for the c_cpp_properties.json file. Fix it like below:
NikoGP commentedon Sep 20, 2017
Even using the code above @bobbrow VSC still complains and says;
"#include errors detected. Please update your includePath. IntelliSense features for this translation unit (E:\program.cpp) will be provided by the Tag Parser. (9, 1) cannot open source file "iostream" (9, 1)"
in the problems section below my code
bobbrow commentedon Sep 20, 2017
What version of MinGW are you using? In your first post, it looked like you had 6.3.0 in your include path. In your most recent post, it looked like you pasted in include paths for 5.3.0 from our MinGW page.
NikoGP commentedon Sep 20, 2017
Okay, I think that my problem lies in the fact that I had installed cygwin prior to MingW, and then I incorrectly installed the required packages for MingW to properly function.
Is there somewhere that I can find what packages I need to install for VS Code to work properly with MingW?
smithalexk commentedon Sep 27, 2017
I am also having the issue seen by @NikoGP with my Intellisense after upgrading to v0.13.0. When I turned on the "Default" setting on the Intellisense engine, I keep receiving an iostream include path error (see attached files). I'm running MacOS 10.12.6, and have updated the LLVM engine as well.
The error under the iostream include is:
#include errors detected. Please update your includePath. IntelliSense features for this translation unit /pathToProgram/) will be provided by the Tag Parser.
cannot open source file "wchar.h" (dependency of "iostream")
Simple "Hello World" example showing the error:

My c_pp_properties.json file:

bobbrow commentedon Sep 27, 2017
@smithalexk, for me, this file resides in
/usr/include
. What doesclang -Wp,-v -E -xc -x c++ /dev/null
show as your include path? The "includePath" in your c_cpp_properties.json file should match that.37 remaining items
Ladinstar commentedon Feb 28, 2018
Hello here ! I have the same problem but i use codeblocks in windows to compile. Help me please !
sean-mcmanus commentedon Feb 28, 2018
@Ladinstar Can you provide more repro info, preferably in a new issue: https://github.com/Microsoft/vscode-cpptools/issues/new .
Ladinstar commentedon Mar 2, 2018
thank you i have founded the solution !
admercs commentedon May 29, 2018
Note to MacOS users, if you are using
gcc
version 8.1.0 (for example) from Homebrew, your MacOS configuration should look like this:Very simple. You do not need to include headers from XCode. Do not set
compilerPath
to/usr/local/bin/gcc-8
, as this is a symbolic link that may mess up IntelliSense. If you are still having issues as I did, set the following user setting insettings.json
as others have to get around a recent issue:"C_Cpp.intelliSenseEngine": "Tag Parser",
prdas31 commentedon Aug 12, 2018
What include files needed to run my code using cl.exe from MSVS 2015?
I've included these folders in c_cpp_properties.json:
But still I get an error while try to build:
sean-mcmanus commentedon Aug 13, 2018
@adam-erickson There's a crashing bug with gcc 8.1 you may be hitting (#2328 ) -- our latest insider release has the fix: https://github.com/Microsoft/vscode-cpptools/releases/tag/v0.17.8-insiders .
@prdas31 Our extension doesn't currently support any build features -- the c_cpp_properties.json is for the IntelliSense feature and not actual compiling. For building with MSVS 2015, you may need to build from the developer command prompt that ships with VS.
prdas31 commentedon Aug 15, 2018
Thanks a lot for the clarification and suggestion. I now use build files to include the paths like this:
This idea is taken from an VSCODE extension called Easy C/C++ Project.
Thanks.
leslienguyn commentedon Sep 29, 2018
[issue moved]
bobbrow commentedon Oct 1, 2018
@leslienguyn, I moved your issue to #2582. This issue is closed.