0

I don’t understand why I cannot find make_shared from std::memory or std::tr1 include header.

I only see 1 version of gcc in my machine

ls -lh /usr/bin/g++
lrwxrwxrwx 1 root root 7 Sep 22  2012 /usr/bin/g++ -> g++-4.7

And I am using -std=c++11 tag in the project build property as well

My environment:ubuntu ecplise juno R2 CDT

#include <memory>
#include <tr1/memory>
int main()
{
    std::tr1::shared_ptr<int> t = std::tr1::make_shared<int>(1);

    std::shared_ptr<int> t = std::make_shared<int>(1);

}

Update:

The build in eclipse console window shows it is actually success, but the code editor keep red underline the shared_ptr and make_shared. I tried to rebuild index, clear project. Nothing can remove the error. Any suggestions?

16:15:09 **** Incremental Build of configuration Debug for project test ****
make all 
Building target: test 
Invoking: GCC C++ Linker
g++  -o "test "  ./main.o   
Finished building target: test 


16:15:09 Build Finished (took 328ms)

Update 2:

Below link solved my issue Enable C++11 in Eclipse CDT (Juno/Kepler/Luna) indexer

Community
  • 1
  • 1
Bryan Fok
  • 3,277
  • 2
  • 31
  • 59
  • Please add an example program and an example of the `g++` call used to compile it. – Mankarse Apr 14 '13 at 04:54
  • Your code works well(second case) even with g++ 4.6.3([LWS example](http://liveworkspace.org/code/1r1dcl$0)). – awesoon Apr 14 '13 at 05:15
  • The "works well" case has an interesting difference in compiler options: `-std=c++0x`. – Bo Persson Apr 14 '13 at 06:03
  • @BoPersson, it's because g++ 4.6.3 doesn't know about `-std=c++11` option, but g++ 4.7 does. – awesoon Apr 14 '13 at 06:20
  • Build was success, but eclipse keep showing errors... – Bryan Fok Apr 14 '13 at 08:23
  • 1
    The Update has changed your question completely. You should change the title and focus on your actual problem, e.g. remove the misleading introduction, show a screenshot (since it is a representational problem), et cetera. – Zeta Apr 14 '13 at 08:28
  • http://stackoverflow.com/questions/13635079/enable-c11-in-eclipse-cdt-juno-indexer Solution from this link solved my problem – Bryan Fok Apr 14 '13 at 09:23

0 Answers0