Author Topic: CodeBlocks Method Code completion  (Read 10955 times)

Offline gtg

  • Single posting newcomer
  • *
  • Posts: 4
CodeBlocks Method Code completion
« on: April 05, 2017, 12:37:22 am »
Hello, I have the following problem. When i try to use some method from the "string" variable the intellisense/SmartSence is not showing the available methods. The code is compiled fine, but it's really frustrating to not have helping intellisense. The interesting thing is that if i disable SmartSence, the available methods are showing, plus alot other option that are not useful. I'm using Linux, ubuntu 16.04, Codeblocks version 16.01 - wx2.8.12 64bit, gnu gcc compiler. Some help will be appreciated.  :)

Offline yvesdm3000

  • Almost regular
  • **
  • Posts: 225
Re: CodeBlocks Method Code completion
« Reply #1 on: April 05, 2017, 07:13:20 am »
What extension has your filename ?

Yves
Clang based code completion for Code::Blocks:   http://github.com/yvesdm3000/ClangLib

Offline gtg

  • Single posting newcomer
  • *
  • Posts: 4
Re: CodeBlocks Method Code completion
« Reply #2 on: April 05, 2017, 09:46:27 am »
the extention of the file is .cpp

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CodeBlocks Method Code completion
« Reply #3 on: April 05, 2017, 09:52:09 am »
Can you post a minimal example?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline gtg

  • Single posting newcomer
  • *
  • Posts: 4
Re: CodeBlocks Method Code completion
« Reply #4 on: April 05, 2017, 01:11:30 pm »
Code
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string str = "String";
    int strSize = str.size();
    cout << "String Size is " << strSize << endl;
    return 0;
}

Here is the code. It is compiled and works properly (it outputs the size of the string). The problem is that after the str (str is the string variable/object) when I write "." (the dot) intellisense/SmartSence is no't showing the possible methods. Btw thx for the attention. guys.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CodeBlocks Method Code completion
« Reply #5 on: April 05, 2017, 08:45:10 pm »
What compiler version are you using?
I guess is newer than 5.x and so you're probably using the new c++abi, which uses c++11 features which our parser doesn't support.

I can reproduce the problem when I switch my compiler to GCC 6.3.0.

@ollydbg: Can you try to reproduce this problem?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks Method Code completion
« Reply #6 on: April 06, 2017, 02:34:22 am »
OK, I see the code suggestion of "str." under GCC 6.3 does not work, because the "basic_string" is now under a namespace inside namespace std.

Question: Where dose the actual "std::string" type actually defined? It should to connected to "std::__cxx11::basic_string<char>" or similar things.

See the image shot below:


« Last Edit: April 06, 2017, 02:40:23 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeBlocks Method Code completion
« Reply #7 on: April 06, 2017, 03:16:10 am »
Some related report on other IDEs:
[QTCREATORBUG-16086] Refactoring fails for std::string on GCC 5 with C++11 ABI - Qt Bug Tracker

[QTCREATORBUG-15461] wrong autocompletion for std::string argument of a function with gcc5 - Qt Bug Tracker

It looks like QTcreator are moving to libclang, so they won't solve this issue in their current build-in parsers.

And some article about this "inline namespace", in-fact, I don't know what does the "inline namespace" means, does it means

std::string == std::__cxx11::string?

See this document: GCC compatibility: inline namespaces and ABI tags - Christian Aichinger's thoughts

EDIT: c++ - What are inline namespaces for? - Stack Overflow, it looks like my guess is right?
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: CodeBlocks Method Code completion
« Reply #8 on: April 06, 2017, 08:25:58 am »
Yes, they use it to provide new mangled names for the changed types and they still provide the old mangled names for old code.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline gtg

  • Single posting newcomer
  • *
  • Posts: 4
Re: CodeBlocks Method Code completion
« Reply #9 on: April 06, 2017, 09:02:21 pm »
Sorry for the late comment. Wow thanks for help and the attention. How must i proceed change (I'm newbie into the c++/oop programing) the gnu gcc compiler version / c++ version , or there I must do some other changes. Thanks again.

Offline NAbdulla

  • Single posting newcomer
  • *
  • Posts: 2
Re: CodeBlocks Method Code completion
« Reply #10 on: July 07, 2019, 07:13:16 pm »
Is there any nightly build which solves the issue ie: which nightly build works with mingw-w64 6.x.x or later versions and support string object method completion?
« Last Edit: July 07, 2019, 07:16:51 pm by NAbdulla »

Offline NAbdulla

  • Single posting newcomer
  • *
  • Posts: 2
Re: CodeBlocks Method Code completion
« Reply #11 on: February 27, 2020, 05:13:12 pm »
What compiler version are you using?
I guess is newer than 5.x and so you're probably using the new c++abi, which uses c++11 features which our parser doesn't support.

I can reproduce the problem when I switch my compiler to GCC 6.3.0.

@ollydbg: Can you try to reproduce this problem?

I am facing this issue with latest nightly build and gcc 8.1 mingw32. was it resolved in this version?

stanB

  • Guest
Re: CodeBlocks Method Code completion
« Reply #12 on: April 03, 2022, 06:37:44 pm »
A quick but ugly fix to this problem is to have an extra namespace in your code ie.

Code
using namespace std;
using namespace std::__cxx11;