2014-06-15 72 views
1

我在Windows 7上使用Emacs 24.3。我使用ELPA安裝了auto-complete-modeautocomplete-c-headersEmacs自動完成c頭。 Symbol作爲變量的值爲void

.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

切換到您的.cpp文件,並使用M-:評估(調試(C++ - 模式t)),這將打開調試器的錯誤,並希望告訴你哪個變量導致問題。 –

回答

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" ) )

嘗試。

+0

是的,我這樣做過。您的評論有點晚,希望謝謝。 – user3003873

+0

不客氣。 – abdimuna