I installed YCM and syntastic for VIM, normally they work fine, but I have problem when it detect some errors in my code, it shows that can NOT find some head files(which is my project head file).
My directory tree shows below:
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
I copied a .ycm_extra_conf.py
to the TOP, meanwhile, I will generated tag
and cscope
file at TOP as well, therefore each time I open file on TOP, like:
howchen@host:~/Work/c/sample/src
-> gvim ./driver/driver.c
to make sure each time I can add tag
and cscope
file in VIM. The problem is, if I open driver.c
, which contain head files: driver.h
, driver_ddi.h
, debug.h
, common.h
, code like below:
#include <stdio.h>
#include <stdlib.h>
#include "math.h"
#include "common.h"
#include "debug.h"
#include "driver_ddi.h"
#include "driver.h"
the syntastic
or YCM
always show it can NOT find common.h
and debug.h
, other head files are OK.
My YCM and syntastic config part in vimrc file:
" 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
My .ycm_extra_conf.py
write flags
variable as:
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'
]
any wrong flags I set?
Moved here from the question.
I found the problem:
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',
]
I missed a comma and path should be ./xxx
, also neeeeed '-I/usr/include'
, and '-I/usr/local/include'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With