YouCompleteMe不能使用C ++ 11

时间:2016-11-05 01:21:22

标签: vim youcompleteme

我在Vim上使用YouCompleteMe插件遇到了问题。

我正在使用macOS。遵循安装准则,我使用--clang-completer选项进行安装。当我编写C ++ 03代码时,它工作正常。但是当我添加一些C ++ 11代码时,插件开始抱怨。

尝试:YcmDiags后,显示如下:

Work/spike/cpp/main.cpp|7 col 12 error| rvalue references are incompatible with C++98
Work/spike/cpp/main.cpp|18 col 10 error| rvalue references are incompatible with C++98
Work/spike/cpp/main.cpp|18 col 5 error| 'auto' type specifier is incompatible with C++98

因此,似乎YouCompleteMe确实识别了C ++ 11,但编译选项有些不对劲。我查看.ycm_extra_config.py,其中包含:

flags = [
'-Wall',
'-Wextra',
'-Werror',
'-Wc++98-compat',
'-Wno-long-long',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
# source code needs it.
'-DUSE_CLANG_COMPLETER',
# THIS IS IMPORTANT! Without a "-std=<something>" flag, clang won't know which
# language to use when compiling headers. So it will guess. Badly. So C++
# headers will be compiled as C headers. You don't want that so ALWAYS specify
# a "-std=<something>".
# For a C project, you would set this to something like 'c99' instead of
# 'c++11'.
'-std=c++11',
# ...and the same thing goes for the magic -x option which specifies the
# language that the files to be compiled are written in. This is mostly
# relevant for c++ headers.
# For a C project, you would set this to 'c' instead of 'c++'.
'-x',
'c++',
'-isystem',
'../BoostParts',
'-isystem',
# This path will only work on OS X, but extra paths that don't exist are not
# harmful
'/System/Library/Frameworks/Python.framework/Headers',
'-isystem',
'../llvm/include',
'-isystem',
'../llvm/tools/clang/include',
'-I',
'.',
'-I',
'./ClangCompleter',
'-isystem',
'./tests/gmock/gtest',
'-isystem',
'./tests/gmock/gtest/include',
'-isystem',
'./tests/gmock',
'-isystem',
'./tests/gmock/include',
'-isystem',
'/usr/lib/c++/v1'
]

这是来自互联网的默认配置。但我看到-std=c++11,为什么它不起作用?有什么帮助吗?

0 个答案:

没有答案