天天看點

syntastic C 搜尋檔案情況一: syntastic + YCM導緻情況二:頭檔案不在include裡

解決xxx.h not found 頭檔案找不到, 然後滿螢幕标紅的問題

情況一: syntastic + YCM導緻

由于youcompleteme會禁用掉syntastic, 是以關閉YCM對C/C++的文法檢查即可。

檢視syntastic是否正常工作

:SyntasticInfo

Syntastic version: .- (Vim , Linux, GUI)
Info for filetype: c
Global mode: active
Filetype c is active
The current file will be checked automatically
Available checkers: gcc make
Currently enabled checker: gcc
Press ENTER or type command to continue
           

如果Currently enabled checker顯示disabled by youcompleteme就在

.vimrc

中加入下行

let g:ycm_show_diagnostics_ui = 0 "0表示禁用ycm自帶的syntastic插件

情況二:頭檔案不在include裡

通常syntastic會自動檢查include,../include

.vimrc

中加入:

let g:syntastic_c_config_file = '.syntastic_c_config'
let g:syntastic_cpp_config_file = '.syntastic_c_config'
           

那麼需要在項目根目錄下寫個配置檔案.syntastic_c_config。

每個檔案夾占一行

-I yourlib/
-I yourlib/subdir
           

繼續閱讀