我知道在这方面已经存在的问题,但我不能通过评论来调查,因为我没有足够的声誉。
因此,我在vim中使用语法,并希望编译c++内容。
我的vimrc看起来是这样的:
72 set statusline+=%#warningmsg#
73 set statusline+=%{SyntasticStatuslineFlag()}
74 set statusline+=%*
75
76 " let g:syntastic_cpp_compiler = 'g++'
77 let g:syntastic_cpp_compiler_options = ' -std=c++11'
78
79 let g:syntastic_always_populate_loc_list = 1
80 let g:syntastic_auto_loc_list = 1
81 let g:syntastic_check_on_open = 1
82 let g:syntastic_check_on_wq = 0我的程序是这样的:
1 #include <functional>
2
3 using namespace std;
4
5 int f(int x){
6 return x;
7 }
8
9 void f2(function<int(int)> f){
10
11 }
12
13 int main(){
14 return 0;
15 }如果我将vimrc中的第76行"clang++“替换为"g++”,则会得到以下错误:
1 diff.cpp|11 col 6 error| variable has incomplete type 'void'
2 diff.cpp|11 col 11 error| use of undeclared identifier 'function'
3 diff.cpp|11 col 33 error| expected '(' for function-style cast or type construction
4 diff.cpp|11 col 46 error| expected '(' for function-style cast or type construction
5 diff.cpp|11 col 48 error| expected ';' after top level declarator如果我只需删除第77行并在其中使用g++进行编译,我就会得到:
1 test.cpp|9 col 9 error| variable or field ‘f2’ declared void
2 test.cpp|9 col 9 error| ‘function’ was not declared in this scope
3 test.cpp|9 col 18 error| expected primary-expression before ‘int’最后,如果我像这里所看到的那样编译程序,我将完全没有语法检查。如果我然后编译,我会得到:
test.cpp:9:9: error: variable or field ‘f2’ declared void
void f2(function<int(int)> f){
^
test.cpp:9:9: error: ‘function’ was not declared in this scope
test.cpp:9:18: error: expected primary-expression before ‘int’
void f2(function<int(int)> f){为什么是这样,我应该添加哪些检查器来简单地编译c++11文件?它真的令人沮丧
发布于 2018-06-24 06:44:17
设g:syntastic_cpp_compiler_options =‘-std=c++11’
在vimrc的第77行中有一个小错误。它应该是
let g:syntastic_cpp_compiler_options = ' --std=c++11'注意std=c++11之前的两个破折号
https://stackoverflow.com/questions/37198268
复制相似问题