Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 322230 - std::shared_ptr and std::unique_ptr not understood
Summary: std::shared_ptr and std::unique_ptr not understood
Status: RESOLVED WORKSFORME
Alias: None
Product: CDT
Classification: Tools
Component: cdt-indexer (show other bugs)
Version: 7.0   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact: Markus Schorn CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-10 09:33 EDT by Wouter CLA
Modified: 2010-08-13 10:36 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Wouter CLA 2010-08-10 09:33:59 EDT
Build Identifier: 201006141710

Eclipse doesn't understand std::shared_ptr instances.
It doesn't know that foo is a pointer in {std::shared_ptr<Foo> foo(new Foo());}, so it wont allow autocompletion after foo-> nor F3 the 'greet' method in foo->greet();

Note that it does understand the older std::auto_ptr.  Basically, std::shared_ptr and std::unique_ptr instances should be treated similar as std::auto_ptr by the indexer.

Reproducible: Always

Steps to Reproduce:
1. Try to use F3 to jump from foo->greet() to the function definition of 'greet'  (see code fragment below).  Alternatively you can also try foo->[autocompletion by ctrl-spacebar]

class Foo
{
    public:
    Foo() 
    {
        printf("constructor Foo\n");
    }
    ~Foo()
    {
        printf("destructor Foo\n");
    }
    void greet() 
    {
        printf("Hello from Foo\n");
    }
};


#include <memory>

void 
mainproc(void)
{
    std::shared_ptr<Foo> foo(new Foo());
    printf("count = %ld\n", foo.use_count());
    foo->greet();
}
Comment 1 Markus Schorn CLA 2010-08-13 07:21:11 EDT
I assume you are using gcc to compile your code. The std::shared_ptr is only  available when using the -std=gnu++0x command line option. With this option a bunch of defines is set differently, most notable __GXX_EXPERIMENTAL_CXX0X__ will be defined.
To make the indexer pick up the c++0x parts of the headers you need to pass the -std=gnu++0x option for the inspection of the compiler (Project Properties - Build - Scanner Discovery)
Be aware that the changes to the tab are not always picked up automatically, I usually have to delete the project from the workspace and reimport it. You can check whether it worked by looking at the Path&Symbols page.

I have tested your code with CDT 7.0 and gcc 4.4.0. In this combination it works.
Comment 2 Wouter CLA 2010-08-13 10:36:05 EDT
Thanks! It now works for me also.
Deleting and importing the workspace again was no solution for me though.  I had to create a new workspace and import the existing project again (same config: gcc 4.4 and CDT 7).