diff --git a/autoload/syntastic/c.vim b/autoload/syntastic/c.vim index 8d329490..43536963 100644 --- a/autoload/syntastic/c.vim +++ b/autoload/syntastic/c.vim @@ -53,6 +53,17 @@ function! s:Unique(list) return l endfunction +" convenience function to determine the 'null device' parameter +" based on the current operating system +function! syntastic#c#GetNullDevice() + if has('win32') + return '-o nul' + elseif has('unix') || has('mac') + return '-o /dev/null' + endif + return '' +endfunction + " get the gcc include directory argument depending on the default " includes and the optional user-defined 'g:syntastic_c_include_dirs' function! syntastic#c#GetIncludeDirs(filetype) diff --git a/syntax_checkers/c/gcc.vim b/syntax_checkers/c/gcc.vim index 359e0dd1..fcbed17f 100644 --- a/syntax_checkers/c/gcc.vim +++ b/syntax_checkers/c/gcc.vim @@ -11,7 +11,6 @@ "============================================================================ " In order to also check header files add this to your .vimrc: -" (this usually creates a .gch file in your source directory) " " let g:syntastic_c_check_header = 1 " @@ -108,6 +107,7 @@ function! SyntaxCheckers_c_GetLocList() if exists('g:syntastic_c_check_header') let makeprg = 'gcc -c '.shellescape(expand('%')) . \ ' ' . g:syntastic_c_compiler_options . + \ ' ' . syntastic#c#GetNullDevice() . \ ' ' . syntastic#c#GetIncludeDirs('c') else return [] diff --git a/syntax_checkers/cpp.vim b/syntax_checkers/cpp.vim index eeb4d839..5b119fa0 100644 --- a/syntax_checkers/cpp.vim +++ b/syntax_checkers/cpp.vim @@ -107,16 +107,9 @@ function! SyntaxCheckers_cpp_GetLocList() if expand('%') =~? '\%(.h\|.hpp\|.hh\)$' if exists('g:syntastic_cpp_check_header') - if has('win32') - let null_device = '-o nul' - elseif has('unix') || has('mac') - let null_device = '-o /dev/null' - else - let null_device = '' - endif let makeprg = g:syntastic_cpp_compiler.' -c '.shellescape(expand('%')) . \ ' ' . g:syntastic_cpp_compiler_options . - \ ' ' . null_device . + \ ' ' . syntastic#c#GetNullDevice() . \ ' ' . syntastic#c#GetIncludeDirs('cpp') else return []