如何为当前项目include PATH配置.ycm_extra_conf.py

如何为当前项目include PATH配置.ycm_extra_conf.py,c,vim,makefile,clang,youcompleteme,C,Vim,Makefile,Clang,Youcompleteme,我安装了YCM和syntastic for VIM,通常它们工作正常,但当它检测到我的代码中的一些错误时,我遇到了问题,这表明找不到一些头文件(这是我的项目头文件) 我的目录树如下所示: TOP ├── debug │   ├── debug.c │   ├── debug.h │   ├── debug.mk │   └── instrument.c ├── driver │   ├── driver.c │   ├── driver_ddi.c │   ├── driver_ddi.h │ 

我安装了YCM和syntastic for VIM,通常它们工作正常,但当它检测到我的代码中的一些错误时,我遇到了问题,这表明找不到一些头文件(这是我的项目头文件)

我的目录树如下所示:

TOP
├── debug
│   ├── debug.c
│   ├── debug.h
│   ├── debug.mk
│   └── instrument.c
├── driver
│   ├── driver.c
│   ├── driver_ddi.c
│   ├── driver_ddi.h
│   ├── driver.h
│   └── driver.mk
├── include
│   └── common.h
├── libs
├── Makefile
├── mw
│   ├── manager.c
│   └── mw.mk
└── root
    ├── main.c
    └── root.mk
我在顶部复制了一个
.ycm\u extra\u conf.py
,同时,我也会在顶部生成
标记
cscope
文件,因此每次打开顶部的文件,如:

howchen@host:~/Work/c/sample/src
-> gvim ./driver/driver.c
确保每次我都可以在VIM中添加
标记
cscope
文件。问题是,如果我打开
driver.c
,其中包含头文件:
driver.h
driver\u ddi.h
debug.h
common.h
,代码如下:

#include <stdio.h>
#include <stdlib.h>
#include "math.h"
#include "common.h"
#include "debug.h"
#include "driver_ddi.h"
#include "driver.h"
My
.ycm\u extra\u conf.py
write
flags
变量为:

" YCM
"   let g:ycm_extra_conf_globlist = ['~/.vim/bundle/YouCompleteMe/cpp/ycm/*','!~/*']
    let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/cpp/ycm/.ycm_extra_conf.py'

" Syntastic
    let g:syntastic_c_checkers=['make']
    let g:syntastic_always_populate_loc_list = 1
    let g:syntastic_check_on_open=1
    let g:syntastic_enable_signs=1
    let g:syntastic_error_symbol = '✗'
    let g:syntastic_warning_symbol = '⚠'
    set statusline+=%#warningmsg#
    set statusline+=%{SyntasticStatuslineFlag()}
    set statusline+=%*gbar
flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', #I don't know if I need remove -x
'c',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'../driver'
'-I',
'../debug'
'-I',
'../include'
'-I',
'../include'
]
我设置了错误的标志吗?

从问题移到这里

我发现了问题:

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-std=c99',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x', #I don't know if I need remove -x
'c',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I./driver',
'-I./debug',
'-I./include',
]

我漏掉了一个逗号,路径应该是
/xxx
,也需要
'-I/usr/include'
,和
'-I/usr/local/include'

,再次尝试他们的问题跟踪器。@romainl,我尝试过,但无应答Syntastic找不到头文件时会出现什么症状?底部第4行缺少逗号如果.ycm_extra_conf.py位于顶部目录,则调试路径应为./debug,而不是../debug。ycm使用基于.ycm_extra_conf.py文件路径的相对路径。