C code autocomplete in Eclipse - c

I'm a Java developer and I've downloaded the Eclipse for C (course purposes) and to my amazement the control+space shortcut (for autocomplete) did not work.
I've created a new project and a new class using the wizzards and started to type "print" and then tried to find an autocomplete feature.
After a bit of googling I arrived at C/C++->Editor->Content Assist->Advanced and there I verified that Help proposals,Parsing-based proposals and Template proposals options were checked.
I then went over to the Keys preferences page using the link at that page and entered a binding for all relevant content assist from before C\C++ Content Assist (type...) and chose in the When box the C\C++ Editor option.
But alas no autocompletion was offered.
Can someone please point me to the right direction?
UPDATE: I'm accepting the answer not because I'm sure it's right but because I've realised I've made some mistakes with the configuration of the eclipse and have seen that with another installation/configuration (i.e. a friend of mines) eclipse does auto complete, even if it still lack many of the java version features.

Use the Advanced panel in the Preferences window to configure the behavior of the Content Assist (Ctrl+Space) command. Go to Preferences->C/C++->Editor->Content Assist->Advanced. Check the parsing-based-Proposals in Default Proposal kinds.

Although the eclipse doesn't provide perfect auto-complete, but it works..
This sometimes happens when you have the indexer turned off.
Try to enable the indexer and rebuild the index.
See this question in CDT FAQ. It contains info about how to find indexer error which might prevent auto-complete.

I'm no Eclipse expert (and I don't even play one on TV), but it might be that it only autocompletes function names that are declared in the current scope - have you added #include <stdio.h> to the top of your source file to get the declarations for the standard I/O functions?

You should verify that you have the gcc home (i.e. C:\MinGW-4.4.1\bin) defined in the path environment variable (if you're using windows and if not then it's equivelant). Also verify that the file has a .c suffix and that the indexer is on as yousf said.
I think, not sure, that you need to then run eclipse with the -clean flag and the autocomplete will work.
Ittai

i answered it here:
Eclipse: How to add include path to be used by autocompletion
You have to explicitly tell it where to find the header:
⇒ Right click on your project ⇒ go to 'C/C++ Include Paths and
Symbols' ⇒ select 'Add External Include Path...' ⇒ browse
to the location of your header files ⇒ refresh

Maybe it is related with KeyAssist bindings.
If you have tried with content assist:
Enter into Window > Preferences. Menu "General" -> "Keys"
Inside search for "Template" and set:
Key Binding to -> "Ctrl + Space"
When: "Editing Test"
Image helper Image Menu Key Assist Code Complete

Vim offers this functionality by scanning your #include's (the shortcut is Ctrl-N, or Ctrl-P to search backwards). If you can't find any better solution, one last resort could be looking into eclim, which integrates vim features into Eclipse (or vice-versa), and that's sure to offer this feature.

Related

How to fix function (that validates input) from not reading a text file? [duplicate]

Trying out the Clion EAP on the Mac. How does one change the current working directory for a launched program? It appears to be set to the output directory of the binaries.
This can be changed via the Run -> Edit Configurations... dialog, just like Idea.
The mix of needing to make changes to CMakeLists.txt for so much of the configuration just threw me, and I've been hunting for a way to change it there, but this bit at least is consistent with the other IDEs, which is good.
Hopefully they'll improve the rest of the Project Settings in a similar fashion.
The "Working Directory" is where the executable starts. Modifying the "Working Directory" in the Configurations setting tells Clion to change to the "Working Directory" after the executable starts execution.
If you want to change where the executable starts execution you will need to add a line to the CMakesLists.txt file.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
add_executable(TimeServer ${SOURCE_FILES})
Position in the cmakes file is important. If you add the set command after the add_executable it will not work. It must come before.
These answers are relatively old. Not sure when the feature was added but there's a very nice UI way to set the current working directory now.
I made a YouTube tutorial for my COSC1030 (Beginning C++) students but the solution is the same for everyone:
https://youtu.be/dTtZEAfh_LM
If you know your CLion fairly well and don't need a demo, here's a short-hand version: Edit Configurations (from drop-down menu at top right of screen), enter the directory you want to use in Working Directory or select via "..." pop-up.

Wrong paths in Codename One preferences

When I need to input a path in Codename One preferences, for example to set up the icon or the certificates to use, I use the browse button. However the path that is then filled up in the associated field leads to the jre (java runtime environnement) folder instead of the parent folder of the file I selected.
Moreover the path is preceded by "file:" where it should not be there.
Here is an example to make it clearer :
As a workaround I manually paste the folder path where the file I want to use resides, and then paste it in the field. So as it is a little bit annoying, I was wondering if I could do something to make it work as it should ?
Please note : my setup involves Eclipse Mars running under Linux 64 with Oracle's Java 8 JDK.
Any help appreciated,
This seems to be related to this issue, I wasn't able to reproduce it in full although I did fix the file: prefix. The paths I got were correct despite all my attempts.
My only guess is that this might be an issue that affected an earlier version of the tool so I've added a version number to the title (1.13 in my current version). If this still happens in the next plugin update and the title of the preferences is 1.13 or newer I'd like to know.

Include tcl.h into C project

I need to use tcl.h in my C project (VS 2012) for registering function in SQLite. I have downloaded Tcl for windows and installed it. But my project still doesn't recognize when I write #include . What should I do to get access to this header?
Thanks in advance.
Open the project properties and do :
Right click on your project, go to properties, go to C/C++ session. On the field Additional Include Directories, add the path to the header you want, and use the header with "".
After that, you should go to the Linker session. On General, go to the Additional Library directories and add the path to the libs you need to add. Then go to Input and add the lib.
Sometimes you will need to copy a dll to the same folder of your executable. You can do that on Custom Build Step - Post Build Events.
You need to do it for each configuration and platform you want to build - one tip to make it easier is to use those variables $(Configuration) and $(Platform) when you are specifying the paths, and select on the dropdown list of the top of the properties window All configurations and All platforms, so you don't need to do it several times per project.

Is there something similar for emacs like vims's NERDtree

For vim there is a filesystem explorer called NERDtree: https://github.com/scrooloose/nerdtree
Surely an alternative or superior package exists for Emacs?
I prefer dirtree (screenshot below) by Ye Wenbin. It feels pretty close to NERDTree / the TextMate drawer.
It took me a few minutes of trial and error to figure out the dependencies, so take a look at the install instructions (and a few minor edits to the source) I've got in this repo.
You can try NeoTree .
https://github.com/jaypei/emacs-neotree
Screenshot:
Have you looked at Speedbar ?
The Sunrise Commander seems to be a well written package, and it has a tree extension. For a screenshot of the tree extension in action, follow this link.
Who needs any tree, when you have the mighty ido-mode . If you can train your mind to find the files, rather than just your eyes whilst visually finding it, you will win. NO need to tell me how biology works, i don't care :-) you get the point.
Personally, I prefer the ECB's tree mode.
http://ecb.sourceforge.net/
You should also check out the CEDET stuff.
http://cedet.sourceforge.net/
They contain a lot of other useful stuff that you can use for similar development needs.
I use a little of emacs-nav and a little of dired to navigate my projects' file trees. For file management tasks, I mostly use bash (often from within emacs).
(Shameless reanswer from A good project tree browser for Emacs? - Stack Overflow)
I just now did a word search for "explore" in package-list-packages, and discovered project-explorer. Seems to fit exactly what I want today (I don't code hardly, but getting a grip on the structure of my Jekyll site).
Keys include TAB for folding and unfolding directories. Open files with RET or f, but with prefix, it will prompt nicely for which window, and even from there allow you to decide to use window or open up a new one to any side (I didn't find the prompt string in the package code, so it seems to leverage built in Emacs functionality nicely; indeed it looks like dired even).
It's available on Melpa and Marmalade, and packaged description points to sabof_project-explorer · GitHub.
I include the site's image for convenience:
I don't use projectile or helm, but it has some integration.
Try out lusty-explorer. It's a well done plugin.
Get it here

Eclipse: choosing a default debugger for all new C projects

Whenever I start a new project, I have to go through setting up the debugger with Eclipse time and time again before I can use it. Isn't there a default setting for all new C projects I can change?
I'm not sure exactly what you mean by "setting up the debugger" (perhaps you can clarify), but under "Preferences -> Run/Debug -> Launching -> Default Launchers" you should be able to select your preferred launcher for different kind of launch modes. This can also be selected individually for each launch configuration.
Typically it is up to the toolchain and/or project to determine which debugger/launcher is suitable to use for that specific project, but I know there is a bug in CDT which prevents toolchains from properly specifying the default launcher to use.
I only use Eclipse for Java, so I can't give you an authoritative answer. But since no one else seems to be answering:
Java projects have a (more or less) hidden file in the project directory called .project and another one called .settings . I'm not sure if this would apply to the C environment as well, but it seems likely. You may want to look at the set of such "hidden" files for a well set up project and a virginal project side by side to find out which settings make the difference.
Given that information, you may be able to simply edit (perhaps with some assistance from a script you can write yourself) the file(s) in question to do the configuration textually without a lot of mouse clicking.

Resources