diff --git a/syntax_checkers/cpp.vim b/syntax_checkers/cpp.vim index 5fc6111e..473590c0 100644 --- a/syntax_checkers/cpp.vim +++ b/syntax_checkers/cpp.vim @@ -65,10 +65,16 @@ 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(1) + if expand('%') =~? '\%(.h\|.hpp\|.hh\)$' if exists('g:syntastic_cpp_check_header') let makeprg = 'g++ -c '.shellescape(expand('%')). @@ -78,10 +84,6 @@ function! SyntaxCheckers_cpp_GetLocList() 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