I have the following piece of code:
#include <iostream>
using namespace std;
int main()
{
vector<int> v; //Symbol vector could not be resolved
return 0;
}
The IDE complains about "vector": Symbol vector could not be resolved.
If I right click the "vector" keyword -> Source -> Add Include, nothing happens.
If I manually add #include <vector>
, then everything is just fine, the file is indexed and I can use its member functions.
However, I expect the IDE to generate these include files for me, instead of manually adding them. How to setup eclipse to work like this?
I am using Ubuntu 16.04 and Eclipse CDT Neon.
This will only work if another file in your project already includes <vector>
.
The way Add Include works is it searches the project's index for the name it's invoked on. If it finds a binding (function, type, etc.) corresponding to that name in the index, it sees what file declares that binding, and then includes that file for you.
For this to work, the binding corresponding to the name must be in the index already. For bindings declared in files external to your project (such as standard library headers), that will only be the case if the external file is already included by some file in your project.