2

I want code completion for C/C++ functions and variables from headers. I tried to install Auto-complete and Company, but C/C ++ functions/variables aren't complemented.

Here is the relevant portion of my .emacs file:

;; Auto-complete (AC) (require 'auto-complete) (require 'auto-complete-config) (ac-config-default) 
2
  • Please post the relevant part of your init file that shows how you are using auto-complete and/or company. Commented Mar 30, 2016 at 13:25
  • I'm using gist.github.com/soonhokong/7c2bf6e8b72dbc71c93b and gnu.org/software/global which works decently for the relatively small projects that I have. Commented Mar 30, 2016 at 15:24

1 Answer 1

5

A vanilla company install wont quite get you where you want; you'll need to use use something like the company-c-headers package. Tuhdo has written an excellent document on using Emacs as a C/C++ IDE, which has instructions on setting up company-c-headers, along with a lot of other stuff.

I don't know what Emacs version you're using, but in 24.5 with Company, you'd do something like this:

  1. Install the company-c-headers package from MELPA -- M-x package-install company-c-headers
  2. Add this to your emacs config file (init.el / .emacs.d / whathaveyou)

    (require 'company) (add-hook 'global-init-hook 'global-company-mode) (add-to-list 'company-backends 'company-c-headers) 

Note that company-c-headers by default only searches two paths for headers. If you want it to search others, you'll need to add them yourself. (For more on that, see Tuhdo)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.