我在Windows 7上使用Emacs 24.3。我使用ELPA安装了auto-complete-mode
和autocomplete-c-headers
。
至.emacs
我添加了:
(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)
当我在C ++模式下运行时,它会显示错误
Symbol's value as variable is void
答案 0 :(得分:2)
首先通过运行以下命令在计算机上找到C / C ++标头。
gcc -xc++ -E -v -
在我的ArchLinux上,他们就在这里
/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
然后完整的C / C ++自动完成对我有用。
;; 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"
)
)
试试吧。