I have the following code in eclipse for c++ and it's underlining string
and cout
and saying could not be resolved.
#include <string>
#include <iostream>
using namespace std;
int main()
{
string s;
s = "hello world";
cout << s;
return 0;
}
Anyone know why?
edit: screenshot
Edit: I have found a solution thanks everyone (see answers).
I've also had this issue.
I've found out that it is because Eclipse couldn't find all include headers.
This simple and quick solution might fix your problem (for example, when the Eclipse project was moved to a different location on disk, then imported again in Eclipse), if not, jump to the next section (Detailed fix).
Before proceeding check if your toolchain is properly installed.
This answer has been outdated. Proceed if nothing of the above helps
If the previous steps don't help we'll need to setup include directories manually (not recommended though)
The problem was that I needed to have both minGW and MSYS installed and added to PATH.
The problem is now fixed.
I've just replied to the related question given by Vanuan (Eclipse CDT: Unresolved inclusion of stl header), and this is my answer :
You could also try use "CDT GCC Built-in Compiler Settings". Go to the project properties > C/C++ General > Preprocessor Include Path > Providers tab then check "CDT GCC Built-in Compiler Settings" if it is not.
None of the other solutions (play with include path, etc) worked for me for the type 'string', but this one fixed it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With