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)

1 Answer 1


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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.