Reputation: 198
I just started using syntastic for vim, and I'm loving it so far, but I have one tiny issue. If the file extension is not cpp, running ":SyntasticCheck" does absolutely nothing. This is a problem, as I would like to run syntastic on header files as well, with extensions such as ".h" or ".hpp". Can anyone help me out? I'm using 'gcc' as my cpp syntastic-checker, if that helps.
Upvotes: 7
Views: 6527
Reputation: 61
Basically, you need to add the path contains your header files such as
let g:syntastic_c_include_dirs = ['../../include','../include','include']
and turn on the variable to check your header files
let g:syntastic_c_check_header = 1
Moreover, you can also pass flags and options to compiler by
let b:syntastic_c_cflags = '-I/usr/include/libsoup-2.4'
and let g:syntastic_c_compiler_options = '-ansi -DMACRO_NAME'
.
It helps in many conditions i.e. when you have many macro definitions.
You can find more useful options in its official Github. C:gcc checker options
Upvotes: 1
Reputation: 31429
Add the following to your vimrc
let g:syntastic_cpp_check_header = 1
this setting was found by reading the comment at the top of <syntastic>/syntax_checker/cpp/gcc.vim
Upvotes: 5