Author Topic: CodeBlocks Method Code completion  (Read 406 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: 223
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: 9876
Re: CodeBlocks Method Code completion
« Reply #3 on: April 05, 2017, 09:52:09 am »
Can you post a minimal example?
<debugger plugin maintainer>
(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: [Select]
#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: 9876
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?
<debugger plugin maintainer>
(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: 4902
  • 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: 4902
  • 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: 9876
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.
<debugger plugin maintainer>
(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.