Search code examples
c++eclipsec++11cygwin

shared_ptr cannot be resolved


I am using Eclipse Juno, and Cygwin C++ compiler (latest version). I wanted to declare shared_ptr (haven't worked with this pointer before) as..

Included the memory header file.

int main(){

std::shared_ptr <int> pointer;

return 0;
}

but the compiler cannot resolve shared_ptr. To solve this problem I have done the following steps:

  1. properties->c/c++ build->settings->tool settings->Miscellaneous-> other flags-> -c -fmessage-length=0 -std=c++11
  2. properties->c/c++ build->settings->tool settings-> Cygwin C++ linker-> libraries(-l)-> add (-pthread)
  3. C/c++ General->path and symbols->Symbols-> Add- GXX_EXPERIMENTAL_CXX0X into "Name" and left "Value" blank.
  4. C/c++ General -> Preprocessor include Paths, Macros->Entries-> CDT user setting entries->Add-> Preprocessor Macro (from dropdown manue)-> Name: __cplusplus, Value:201103L-> Apply
  5. Index-> Rebuild
  6. Restart Eclipse

Unfortunately, could not solve the problem. It would so nice of you if I get help. Thanks in advance.


Solution

  • You need to #include <memory> in order for the compiler to know about std::shared_ptr.