【问题标题】:Vim YouCompleteMe c++17 : warning on decomposition declarationVim YouCompleteMe c++17:分解声明警告
【发布时间】:2020-02-05 21:13:59
【问题描述】:

我想正确设置 YouCompleteMe,这样我就不会在 c++ 文件中收到以下警告:

...

auto [k,v] = mapIt; // some map iterator

...
decomposition declarations are a C++17 extension

我加了

   flags.append( '-std=c++17' ) 

在

~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py

并添加以下内容

~/.vimrc
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'

【问题讨论】:

  • 我不确定 StackOverflow 是否是为 YouCompleteMe 获得帮助的最佳渠道。建议你看看here.
  • 我已回滚您的编辑。在 Stack Exchange 上回答问题的正确方法是发布答案

标签: vim c++17 youcompleteme


【解决方案1】:

我决定删除之前的安装并从命令行执行所有操作(假设之前的 Vundle 安装按照 YouCompleteMe 文档中的建议进行)。

# typical installation directory for vundle and pathogen
cd ~/.vim/bundle

# clone the repository for YouCompleteMe
git clone https://github.com/Valloric/YouCompleteMe.git
cd YouCompleteMe

# and all submodules
git submodule update --init --recursive

# install
python3 install.py --clang-completer

接下来我创建了一个简单的 ycm_extra_conf.py(没有 .dot),其中包含:

def FlagsForFile ( filename, **kwargs ):
    return {
        'flags': ['-x', '-Wall', '-Wextra', '-Werror', '-std=c++2a']
    }

我添加了 c++2a 标志,但 c++17 也应该可以工作。

然后在你的 ~/.vimrc 文件中指向这个文件。

let g:ycm_global_ycm_extra_conf = '$HOME/.vim/bundle/YouCompleteMe/ycm_extra_conf.py'

注意:你可能需要添加到你的 ~/.vimrc

Plugin 'Valloric/YouCompleteMe'  

在你的 vimrc 文件中。

然后运行(从 vim)

:PluginInstall

我没有执行这些步骤,因为我之前安装了 YouCompleteMe。

这似乎解决了我的问题。希望这对某人有用。

【讨论】:

    【解决方案2】:

    只需将 .ycm_extra_conf.py 中的标志 '-std=c++11' 更改为 '-std=c++17'。

    这对我来说非常有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-05-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多