I am experiencing an issue with my Vscode in C++, where the compiler suggests the iostream header when I type #include< and provides the correct completion for "iostream." However, when I actually include the iostream header (#include ) in my code, the C/C++ (vscode-cpptools) extension complains that it cannot locate the header. However, the code is compiling and running without error both inside Vscode and also from the terminal.
I am using g++ 12.2.0 on Ubuntu 23.0. When I click on #include and go to declaration, it takes me to the "iostream.cpp" file in "/usr/include/c++/12/iostream." This suggests that the header file is present in the standard library.
I have checked my IDE settings and verified that the C/C++ extension is properly installed and configured.
I suspect there might be some system-specific issue or misconfiguration that is causing this problem. Could someone please help me troubleshoot and resolve this issue? Any suggestions or insights into why the compiler suggests the header but cannot locate it during code completion would be greatly appreciated.
Code Sample:
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;}
Compiler Output/Error:
#include errors detected. Please update your includePath.
Squiggles are disabled for this translation unit (/home/Desktop/FinDiff/Mmagsolve/hw.cpp).C/C++(1696)
cannot open source file "bits/c++config.h" (dependency of bits/c++config.h")
Thank you for any assistance you can provide!
NB: this is not a duplicate of this question. I'm already able to compile and run my code in Vscode. Here the problem is this #include errors
. None of the answers there are helpful to fix this particular problem.
Update: The issue is coming for the vscode-cpptools extension which I use for code completion. Even then, the issue is not that it is not able to find iostream files. Inside the definition of iostream, it is not able to find cannot open source file "gnu/stubs-32.h" :
cannot open source file "gnu/stubs-32.h" (dependency of "bits/c++config.h")C/C++(1696)
This is a problem particular to the Vscode-app tools extension. How can I fix this?