Merge remote-tracking branch 'kongo/c_includes'
This commit is contained in:
commit
5794f3fbb9
@ -34,6 +34,13 @@
|
|||||||
" libraries is done. I.e. set the variable like this:
|
" libraries is done. I.e. set the variable like this:
|
||||||
"
|
"
|
||||||
" let b:syntastic_c_cflags = ' -I/usr/include/libsoup-2.4'
|
" let b:syntastic_c_cflags = ' -I/usr/include/libsoup-2.4'
|
||||||
|
"
|
||||||
|
" In order to add some custom include directories that should be added to the
|
||||||
|
" gcc command line you can add those to the global variable
|
||||||
|
" g:syntastic_c_include_dirs. This list can be used like this:
|
||||||
|
"
|
||||||
|
" let g:syntastic_c_include_dirs = [ 'includes', 'headers' ]
|
||||||
|
|
||||||
|
|
||||||
if exists('loaded_c_syntax_checker')
|
if exists('loaded_c_syntax_checker')
|
||||||
finish
|
finish
|
||||||
@ -81,8 +88,23 @@ function! s:Init()
|
|||||||
unlet! s:RegHandler
|
unlet! s:RegHandler
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
let s:default_includes = [ '.', '..', 'include', 'includes',
|
||||||
|
\ '../include', '../includes' ]
|
||||||
|
|
||||||
|
function! s:GetIncludeDirs()
|
||||||
|
let include_dirs = s:default_includes
|
||||||
|
|
||||||
|
if exists('g:syntastic_c_include_dirs')
|
||||||
|
" TODO: check for duplicates
|
||||||
|
call extend(include_dirs, g:syntastic_c_include_dirs)
|
||||||
|
endif
|
||||||
|
|
||||||
|
return join(map(copy(include_dirs), '"-I" . v:val'), ' ')
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! SyntaxCheckers_c_GetLocList()
|
function! SyntaxCheckers_c_GetLocList()
|
||||||
let makeprg = 'gcc -fsyntax-only '.shellescape(expand('%')).' -I. -I..'
|
let makeprg = 'gcc -fsyntax-only '.shellescape(expand('%')).
|
||||||
|
\ ' '.s:GetIncludeDirs()
|
||||||
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
|
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
|
||||||
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
|
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
|
||||||
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
|
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
|
||||||
@ -90,7 +112,8 @@ function! SyntaxCheckers_c_GetLocList()
|
|||||||
|
|
||||||
if expand('%') =~? '.h$'
|
if expand('%') =~? '.h$'
|
||||||
if exists('g:syntastic_c_check_header')
|
if exists('g:syntastic_c_check_header')
|
||||||
let makeprg = 'gcc -c '.shellescape(expand('%')).' -I. -I..'
|
let makeprg = 'gcc -c '.shellescape(expand('%')).
|
||||||
|
\ ' '.s:GetIncludeDirs()
|
||||||
else
|
else
|
||||||
return []
|
return []
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user