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.
Asked
Active
Viewed 6,426 times
7
-
figured it out add this to your vimrc to enable header file checking with gcc syntastic checker: let g:syntastic_cpp_check_header = 1 – Dan Cauley Aug 04 '13 at 18:58
-
4If that solved your problem. post it as an answer. – FDinoff Aug 04 '13 at 21:01
2 Answers
5
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

FDinoff
- 30,689
- 5
- 75
- 96
1
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

Trent Huang
- 61
- 4