Search code examples
cubuntu-14.04qt-creatorcodeblockseclipse-cdt

Unable to get simple C code completion to work in linux on multiple IDEs


I'm trying to find an IDE on linux that will support code completion. For instance in Visual studio for a C project when I do:

#include <stdio.h>

and then start typing "printf" a box will pop up with printf prototypes. I've been trying desperately to get this functionality in a linux ide and have tried several.

Codeblocks: on ubuntu 14.04 I've tried both 13.12 as well as installing 16.01. After putting in #include neither will popup a dialog. "pri" will popup private as a selection only. I've tried enabling and disabling the completion plugin to no avail. And using the hot keys for calltips.

Qt-Creator: vs 3.0.1 that is installed from the ubuntu repos. #include does not popup a printf. I've ensured in the menu settings that completion in the editor is enabled.

Eclise mars: this was a beast to install and get running. I installed it with the C/C++ development mode. I can't find any significant menu settings for code completion but I did ensure that /usr/include (where stdio.h is) is in the include paths. The header files also pop up in a lowerleft box with little locks on them and I can open it after the include statement, but it certainly does not bring up a box with "printf" in it after typing printf...

I've got some functionality of code completion in Atom (from atom.io) after installing clang and a clang-completion plugin. But it frequently crashses :/

Does anyone know how to either get codecompletion where a simple #include will open the header and allow a calltip/code hint/etc box to pop up with the function prototype on any of the above IDEs? or is this not what they mean by "autocompletion". Or do you know of a good ide that would support the functionality I'm seeking specifically?

thanks, I appreciate the help immensely!

EDIT: in response to Ashish and for clarification this is the behavior I am looking for in VS but what's happening in codeblocks. The current codeblocks version I have is 16.01 installed from the ppa "ppa:damien-moore/codeblocks" but the same issue was happening from the original codeblocks i got from "sudo apt-get install codeblocks" visual c completion

and this is what's happening in code::blocks (as well as eclipse, and qt-creator.) it works a little but doesn't actually seem to parse the included header file...>

codeblocks c completion


Solution

  • Well. I couldn't get code::blocks to work, but I finally figured out Qt-creator (phew...was starting to consider going back to visual studio :/)

    The issue for Qt-creator at least was that the desktop kit by default found my Clang compiler automatically but didn't select it in the desktop kit.

    Under the menu: Tools|Options|Build & Run|Kits tab|Desktop (default) and selected the compiler from the pulldown box.

    Code completion is working again.