Merge pull request #198 from kongo2002/cpp_compiler_options
Fix custom compiler options handling for C/C++
This commit is contained in:
commit
ed515fc268
@ -55,17 +55,11 @@ 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(cpp)
|
||||
function! syntastic#c#GetIncludeDirs(filetype)
|
||||
let include_dirs = copy(s:default_includes)
|
||||
|
||||
if a:cpp == 1
|
||||
if exists('g:syntastic_cpp_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_cpp_include_dirs)
|
||||
endif
|
||||
else
|
||||
if exists('g:syntastic_c_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_c_include_dirs)
|
||||
endif
|
||||
if exists('g:syntastic_'.a:filetype.'_include_dirs')
|
||||
call extend(include_dirs, g:syntastic_{a:filetype}_include_dirs)
|
||||
endif
|
||||
|
||||
return join(map(s:Unique(include_dirs), '"-I" . v:val'), ' ')
|
||||
|
@ -64,29 +64,33 @@ endif
|
||||
let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
if !exists('g:syntastic_c_compiler_options')
|
||||
let g:syntastic_c_compiler_options = '-std=gnu99'
|
||||
endif
|
||||
|
||||
function! SyntaxCheckers_c_GetLocList()
|
||||
let makeprg = 'gcc -fsyntax-only -std=gnu99 '.shellescape(expand('%')).
|
||||
\ ' '.syntastic#c#GetIncludeDirs(0)
|
||||
let makeprg = 'gcc -fsyntax-only '
|
||||
let errorformat = '%-G%f:%s:,%-G%f:%l: %#error: %#(Each undeclared '.
|
||||
\ 'identifier is reported only%.%#,%-G%f:%l: %#error: %#for '.
|
||||
\ 'each function it appears%.%#,%-GIn file included%.%#,'.
|
||||
\ '%-G %#from %f:%l\,,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %m'
|
||||
|
||||
" add optional user-defined compiler options
|
||||
let makeprg .= g:syntastic_c_compiler_options
|
||||
|
||||
let makeprg .= ' '.shellescape(expand('%')).
|
||||
\ ' '.syntastic#c#GetIncludeDirs('c')
|
||||
|
||||
" determine whether to parse header files as well
|
||||
if expand('%') =~? '.h$'
|
||||
if exists('g:syntastic_c_check_header')
|
||||
let makeprg = 'gcc -c '.shellescape(expand('%')).
|
||||
\ ' '.syntastic#c#GetIncludeDirs(0)
|
||||
\ ' '.syntastic#c#GetIncludeDirs('c')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
" add optional user-defined compiler options
|
||||
if exists('g:syntastic_c_compiler_options')
|
||||
let makeprg .= g:syntastic_c_compiler_options
|
||||
endif
|
||||
|
||||
" check if the user manually set some cflags
|
||||
if !exists('b:syntastic_c_cflags')
|
||||
" check whether to search for include files at all
|
||||
|
@ -65,23 +65,25 @@ let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
function! SyntaxCheckers_cpp_GetLocList()
|
||||
let makeprg = 'g++ -fsyntax-only '.shellescape(expand('%')).
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(1)
|
||||
let makeprg = 'g++ -fsyntax-only '
|
||||
let errorformat = '%-G%f:%s:,%f:%l:%c: %m,%f:%l: %m'
|
||||
|
||||
if exists('g:syntastic_cpp_compiler_options')
|
||||
let makeprg .= g:syntastic_cpp_compiler_options
|
||||
endif
|
||||
|
||||
let makeprg .= ' ' . shellescape(expand('%')) .
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
|
||||
if expand('%') =~? '\%(.h\|.hpp\|.hh\)$'
|
||||
if exists('g:syntastic_cpp_check_header')
|
||||
let makeprg = 'g++ -c '.shellescape(expand('%')).
|
||||
\ ' ' . syntastic#c#GetIncludeDirs(1)
|
||||
\ ' ' . syntastic#c#GetIncludeDirs('cpp')
|
||||
else
|
||||
return []
|
||||
endif
|
||||
endif
|
||||
|
||||
if exists('g:syntastic_cpp_compiler_options')
|
||||
let makeprg .= g:syntastic_cpp_compiler_options
|
||||
endif
|
||||
|
||||
if !exists('b:syntastic_cpp_cflags')
|
||||
if !exists('g:syntastic_cpp_no_include_search') ||
|
||||
\ g:syntastic_cpp_no_include_search != 1
|
||||
|
Loading…
Reference in New Issue
Block a user