Reputation: 553
I am using Emacs 24.3, on Windows 7. I installed auto-complete-mode
and autocomplete-c-headers
with ELPA.
To .emacs
I added:
(require 'auto-complete)
(add-to-list 'load-path "~/.emacs.d/elpa/auto-complete-20140208.653") ; This may not be appeared if you have already added.
(add-to-list 'ac-dictionary-directories "~/.emacs.d/elpa/auto-complete-20140208.653/dict")
(require 'auto-complete-config)
(ac-config-default)
;|---------------------------------------------------------------+
;|auto-complete c/c++ headers
;|---------------------------------------------------------------+
(add-to-list 'load-path
"~/.emacs.d/elpa/auto-complete-c-headers-20140325.835")
(defun my:ac-c-headers-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(add-to-list 'aсhead:include-directories '"d:/DevTools/env/MinGW/lib/gcc/mingw32/4.8.1/include")
)
(add-hook 'c++-mode-hook 'my:ac-c-headers-init)
(add-hook 'c-mode-hook 'my:ac-c-headers-init)
When I run in C++-mode, it shows the error
Symbol's value as variable is void
Upvotes: 1
Views: 2347
Reputation: 785
First locate C/C++ headers on your computer by running the following command.
gcc -xc++ -E -v -
On my ArchLinux they are located here
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/x86_64-unknown-linux-gnu
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/backward
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include
/usr/local/include
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include-fixed
/usr/include
Then the complete C/C++ auto-completion which works for me is this.
;; C++ auto completion mode
(require 'auto-complete)
(require 'auto-complete-config)
(ac-config-default)
;a function which initializes auto-complete-c-headers and get called for c/c++ hooks
(defun my:acc-c-header-init ()
(require 'auto-complete-c-headers)
(add-to-list 'ac-sources 'ac-source-c-headers)
(add-to-list 'achead:include-directories '" /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/x86_64-unknown-linux-gnu
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/../../../../include/c++/4.9.1/backward
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include
/usr/local/include
/usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.1/include-fixed
/usr/include"
)
)
Try that.
Upvotes: 2