how to add c++11 support to syntastic vim plugin?

Carneiro picture Carneiro · Aug 10, 2013 · Viewed 20.4k times · Source

I am using syntastic in my c++11 project. When I am editing in vim, and save (:w) the syntastic plugin gives me errors on every initializer list {} and for each loops which are clearly c++11 features that it's missing.

I installed syntastic using pathogen.

Here are two examples of the error I am getting on initializer lists and for each loops (both c++11 that compile fine):

error on initializer lists error on for each loop

Answer

Carneiro picture Carneiro · Aug 14, 2013

Turns out the C++ linter (syntax checker) of syntastic has many options that can be set on your .vimrc (unfortunate, I wish it was project specific, like the .clang_complete solution).

To enable c++11 standards and use the libc++ library with clang (which is what my project is using) I added the following lines to my ~/.vimrc

let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'

it now works beautifully.