Code Yarns ‍👨‍💻
Tech BlogPersonal Blog

How to set C++ compiler options for Syntastic

📅 2014-Nov-06 ⬩ ✍️ Ashwin Nanjappa ⬩ 🏷️ cpp, cpp11, plugin, syntastic, vim, warning ⬩ 📚 Archive

To learn how to install and use Syntastic, please see this post.

Syntastic should be able to detect the C++ compiler on your system and use it for syntax checking automatically. If you need to change it or set it explicitly, then add its command or full path to your .vimrc:

let g:syntastic_cpp_compiler = "g++"

You might want to enable some compiler options for Syntastic to apply on your code. For example, I like to add support for C++11 and also rigorously check for warnings, so I add this to my .vimrc:

let g:syntastic_cpp_compiler_options = "-std=c++11 -Wall -Wextra -Wpedantic"

Tried with: GCC 4.9.2, Vim 7.4 and Ubuntu 14.04