I have recently been using Vim as my C++ IDE with the wonderful c.vim plugin . However I have been stymied by implementing C++11 code. I initially thought the answer posted to this nearly identical question here would help. But as I have tried to reset the compiler global variable in my vimrc:
let g:C_CplusCompiler="g++ -std:c++0x"
or
let g:C_CplusCompiler="g++ -std=c++0x"
I keep getting the following error for both scenarios:
E518: Unkown option: -std:c++0x
This compilation does work find, however, if I simply do it in the command line with:
g++ -std=c++0x test.cpp -o test
Am I somehow missing something in the documentation to have vim compile with std-c++0x
?
If your make is gnu-make (and not mingw's one) you just need to set
:let $CXXFLAGS='-std=c++0x -Wall +whatever-other-options'
and then compile you mono file project with
:make %<
If this doesn't work, make sure your compiler support this option. In the shell, try:
CXXFLAGS=-std=c++0x make test
or if your really want to compile by hand:
g++ -std=c++0x -o test test.cpp
With BuildToolsWrappers , for mono-file projects still, you'll need to set $CXXFLAGS, and then type either :Make
, or <F7>
to compile the current mono-file project. And you can run it with <CTRL-F5>
. (Both keybindings can be configured).
NB: BTW plugin also support multi-files projects. Then you'll have to have a Makefile, or equivalent, where the $CXXFLAGS will be set.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.