The dereference operator for unique_ptr does not work in Eclipse

After completing the steps in this post, I managed to get Eclipse (Indigo) to recognize unique_ptr (and other new C ++ 11 stuff). The problem is that operator-> for unique_ptr does not seem to be supported in Eclipse. Here you have an example:

 class Foo { void bar() { /* ... */ } }; std::unique_ptr<Foo> foo; (*foo).bar(); // 1 foo->bar(); // 2 

Case 1 works as expected: there are no errors or autocomplete. However, for case 2 Eclipse marks the instruction with an error ("Panel" Method "cannot be resolved"), as well as autocomplete from foo-> does not work.

The most interesting thing is that I have no problems with std::shared_ptr . This only happens for std::unique_ptr .

Has anyone had the same problem? Does anyone know a way to fix this?

EDIT: for clarification purposes only, the compilation process is suitable for the code snippet shown above. So, the problem is not in the compiler itself, but on Eclipse.

+6
source share
2 answers

I finally found in the CDT a bug report in the CDT describing the very problem that I am suffering. So far, there has not been a real solution to the problem, but there was a workaround in this error message:

Yes, GCC 4.5 is the latest version of GCC whose library headers can be accurately indexed by CDT. The main reason for not indexing 4.6 headers is the lack of CDT support for "constexpr" and "nullptr", which are widely used in 4.6 headers (by the way, is it likely that this will be implemented for Juno?).

I worked on this by installing both GCC 4.5 and 4.6 systems and pointing the CDT to 4.5 headers (by setting the compiler call to the "g ++ - 4.5" command in the Discovery options), actually compiling with 4.6.

0
source

This issue was recently fixed in cdt 8.1.1. Just go to help-> check for updates and it will download and install. I tested unique_ptr and indexed correctly.

0
source

Source: https://habr.com/ru/post/918737/


All Articles