Author Topic: Inconsistent autocomplete behavior between Windows and Linux  (Read 739 times)

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
I am having strange issues when using Code::Blocks in Linux Mint 19.

For instance, if I include the string class and try to declare a string varaible by typing std::string, the autocomplete doesn't show string. It only shows stringbuf and stringstream. The code still works as expected, it just doesn't show in the autocomplete.

Additionally, the autocomplete doesn't work for any of the methods under the string class. For instance, if I have a string variable called str, and then I type str.find, the autocomplete won't appear at all. If I press Ctrl+Space, nothing would happen.

None of these issues happen on Windows.

The reason I need the autocompletion is that I am still new to C++, so having a good autocomplete function helps me a lot.

Any ideas why I am having these weird issues?

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #1 on: June 10, 2020, 01:09:18 am »
I tested it under Linux Mint 19.3 Xfce.... and it works fine...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6956
    • My Best Post
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #2 on: June 10, 2020, 01:49:09 am »
I tested it under Linux Mint 19.3 Xfce.... and it works fine...

This implies it is an missing Linux package or an C::B setting issue.

To the OP: Did you try installing dev pckages related to the missing features?

huycan: Do you have any special settings to make auto completion work in C::B?

Edit2: AbdelrahmanSaid: You did include the correct header, right?

Tim S.
« Last Edit: June 10, 2020, 02:09:47 am by stahta01 »
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #3 on: June 10, 2020, 02:41:57 am »
Ok.... The problem is with the gcc compiler came with Linux Mint 19.3 ... Mine is the gcc 9.3 that I built myself... and that version's working fine... I tested by switching back to gcc 7.5 (came with Linux Mint) and voila... the problem happened just like the OP described....

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #4 on: June 10, 2020, 03:22:09 am »
Thanks for the help, guys. I haven't tested with other versions of the compiler as I only have the one that comes by default at the moment.

Any ideas how can I fix this issue with the current compiler, or do I need to install a new version?

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #5 on: June 10, 2020, 03:30:54 am »
I did try to upgrade the compiler manually by

Code: [Select]
sudo apt-get install gcc-8 g++-8
(They don't have 9 yet... and the current version is 10...)

Anyway, the problem still persists...

So, you might try to build the latest gcc from source....

Side note: I tried on Ubuntu 20 ... (it comes with gcc 9.3) and there is no problem...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2771
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #6 on: June 10, 2020, 09:25:03 am »
How have you installed the  self build gcc?
I think this is some search path issue for the code completion...

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #7 on: June 10, 2020, 10:47:20 am »
I confirm the behavior. I have done a quick test upgrading to gcc-9 from the ubuntu testing repositories and codeblocks immediately started working as expected.

I think this is some search path issue for the code completion...

Any ideas on how to fix it if it is indeed a search path issue?

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #8 on: June 10, 2020, 02:14:41 pm »
How have you installed the  self build gcc?

Use the current gcc compiler in your system and build the new one from the source... It is a lot easy (more straight forward) to do it in Linux than Windows...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 2771
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #9 on: June 10, 2020, 05:03:23 pm »
Quote
Use the current gcc compiler in your system and build the new one from the source... It is a lot easy (more straight forward) to do it in Linux than Windows...
The question was more, how did you use it in codeblocks. How did you give codeblocks the paths... Did you created a package and installed it, or did you used configure --prefix or did you used the default for configure....
installing is not building...

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #10 on: June 10, 2020, 05:36:40 pm »
Quote
Use the current gcc compiler in your system and build the new one from the source... It is a lot easy (more straight forward) to do it in Linux than Windows...
The question was more, how did you use it in codeblocks. How did you give codeblocks the paths... Did you created a package and installed it, or did you used configure --prefix or did you used the default for configure....
installing is not building...

I have just finished doing it. Built gcc-9.3 from source and started using it in codeblocks and it works perfectly.

To do that, all you need to do is, in codeblocks, go to Settings > Compiler, choose the 'Toolchain Executables' tab and point codeblocks to where you have installed the new version of gcc. That is what I have done and it seems to work perfecctly fine for me.

Offline huycan

  • Multiple posting newcomer
  • *
  • Posts: 26
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #11 on: June 10, 2020, 08:57:46 pm »
Actually, you don't have to change any setting in CodeBlocks. I just create a script to change all the soft links in /usr/bin point to appropriate version.... for example, /usr/bin/gcc points to gcc-9.3 instead of gcc-7.5, g++ points to g++-9.3 , etc...  This way, your whole system is using the 9.3 version (even if you use different IDE)... and if you want to switch back to older version, change the links.

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #12 on: June 10, 2020, 10:43:07 pm »
Actually, you don't have to change any setting in CodeBlocks. I just create a script to change all the soft links in /usr/bin point to appropriate version.... for example, /usr/bin/gcc points to gcc-9.3 instead of gcc-7.5, g++ points to g++-9.3 , etc...  This way, your whole system is using the 9.3 version (even if you use different IDE)... and if you want to switch back to older version, change the links.

Yeah.. of course that would be the other option here. I just didn't want to change the gcc version that my system uses, so I switched it in codeblocks.

Offline AbdelrahmanSaid

  • Single posting newcomer
  • *
  • Posts: 9
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #13 on: June 10, 2020, 11:46:31 pm »
Okay. I have encountered another strange issue.

When I declare a variable, let's say an integer called num. If I initialise it with the assignment operator, i.e. int num = 0;, then everything works fine.

However, if initialise it like this int num {0};, then codeblocks would not take that variable into consideration for code completion. If I type start typing the name of the variable, the auto code completion won't appear, and if I try to force it with Ctrl+Space, then codeblocks won't find it. Additionally, if the variable has methods, a string or a vector variable for instance, then none of these methods would show up, because the variable isn't even recognised as a variable.

Any ideas what is happening here?

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12737
    • Travis build status
Re: Inconsistent autocomplete behavior between Windows and Linux
« Reply #14 on: June 10, 2020, 11:48:54 pm »
Any ideas what is happening here?
The CC hasn't been updated to support the stupidly broken modern initialization style which doesn't work (tm) :)
Patches welcome.
(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!]