autocomplete for unique_ptr not working Follow
So with the following example:
std::unique_ptr<std::string> p(new std::string);
p-> (should show std::string functions, instead shows unique_ptr functions)
How do I get the `p->` to show the correct auto complete? This also applies to navigating the code. If I had `p->empty()` and wanted to move to `empty()` it wouldn't know what it was to navigate.
I feel like at one point this worked but doesn't any more, but I don't use code with unique_ptr enough to be sure until lately.
I have invalidated my cache multiple times. I have nuked my cmake-build-* directories and tried reloading cmake/building clean, etc. Nothing seems to make auto complete parse properly.
Edit: no idea how to do code tags on this forum... Tried a few things, didn't work, lol.. sorry. :)
Please sign in to leave a comment.
Could you please specify which compiler and CLion version you are using?
I got the same problem as described in the post.
Build #CL-171.4694.31, built on June 8, 2017
Also my smart pointers are marked red when using members, like this:
When hovering currentScreen_ it says
"Applying '->' operator to 'unique_ptr<GameScreen>' instead of a pointer."
My project compiles just fine. I also do think that the behaviour occured the first time after updating Clion the last time.
Yea I have the exact environment that Tobias has.
Gcc 7.1.1 and just updated to 2017.1.3, but I did that in an attempt to fix the issue, so it was present in 2017.1.2.
I recently upgraded to gcc 7 (a week or 2 ago) so that could be the issue. I swear I remember this working before.
Edit: also have the same "red" behavior that he has on using the pointer too. How did you do a code block btw? lol
@Mike you could be right with GCC causing this behaviour.
Regarding the code block: I just copied from Clion and pasted xD
Yea I'm pretty sure that's the issue since the warning it shows me in Clion talks about the "new Whatever" passed into the unique_ptr is not of type "remove_reference<...>". Which is not the right definition of the function when I navigate to it.
Hopefully Anna can help us find a workaround though since this project I'm on right now has a lot of unique_ptr and shared_ptr. :)
We are sincerely sorry for the inconvenience. We have the issue in the tracker already: https://youtrack.jetbrains.com/issue/CPP-9949. It's a bug in CLion related to the latest GCC version support. Please add your comment or upvote. Hope it will be fixed soon.
Thanks Anna! I figured it was created by the new gcc since it seemed to work before and that is the only change I can think of recently. I will upvote the bug although I'm sure they will work on it quickly as it will affect a lot of linux users. :)
I'm still having this issue on the latest version of CLion.
See the example code below:
I 'm experiencing the same problem with std::shared_ptr.
Could you check if this is a bug?
Build #CL-181.4203.549, built on March 27, 2018
Licensed to ##### ####
You have a perpetual fallback license for this version
Subscription is active until April 27, 2019
JRE: 1.8.0_152-release-1136-b20 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Running on Ubuntu Xenial
% c++ --version
c++ (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
@Hideo-t, please update CLion to 2018.1.2 and check whether the issue still persists.
It worked as expected with 2018.1.2. Great!
I didn't notice that I was one release behind the latest release.
I switched to using JetBrains Toolbox so I won't miss future releases.
Hi everyone, I'm using the 2019.1.2 version and the autocompletion using shared_ptr doesn't work, I don't see any error but I just don't see what I can use.
Do I need to change anything with this version of CLion? thank you
@Emin Demiri, is your project CMake-based? Does it behave the same way in a default "Hello, World!" project (File | New Project > C++ Executable)?
@Anna Falevskaya my project is a djinni projet ans is based on CMake.
On VisualStudioCode the same project autocomplete all functions of any objects.
@Emin Demiri, does the issue happen in "Hello, World"?
@Anna Falevskaya when creating a new project, working correctly.
I don't know if it helps at all but I have a Djinni project that I'm working on... weird coincidence since I started this thread ages ago before I had even knew about djinni, lol.
Anyway, with the most recent clion I just tested my project and it finds the shared_ptr autocompletion just fine, just like VSCode does. My guess is you have a configuration issue somewhere in your cmake and it's not able to resolve the shared_ptr properly.
Here's a screenshot showing it working. Sorry I couldn't show more it's proprietary code that I wouldn't have rights to share but this one line example won't hurt anyone.
Corresponding djinni code:
Side note, as much as I love jetbrains and clion I've been using vscode for this djinni project because of the need to hop between c++, java, and objective-c all the time. CLion can't handle that so I find I just naturally end up using vscode. Using clion on a djinni project is just not as useful since it mixes those languages.