【问题标题】:Why YouCompleteMe does not work after dot?为什么 YouCompleteMe 在 dot 之后不起作用?
【发布时间】:2016-01-22 21:56:31
【问题描述】:

我已经按照安装指南安装了YouCompleteMe。我在 Windows 机器上使用 gVim。基本的符号完成正在工作,但我无法从我的标题中自动完成。

如果我有:

#include <vector>
using namespace std;
vector<int> myVector;

那么myVector.&lt;smth like push_back etc...&gt;将找不到完成

Vim 状态栏说:

--User defined completion (^U^N^P) Pattern not found

--Omni completion (^O^N^P) Pattern not found

诊断

我开始诊断问题。 :YcmDiags 命令给出来自头文件的错误列表。由于 YouCompleteMe 使用 clang 来不断编译源代码,因此我尝试使用 clang 编译我的文件。我也知道我应该在 .ycm_extra_conf.py 的标志中为 clang 指定命令行选项。我不知道 YCM 是运行 clang.exe 还是 clang-cl.exe 但我实际上使用 clang-cl.exe 从命令行运行 vsvars32.bat 后手动。使用 clang.exe 编译没有成功。

这是我的 .ycm_extra_conf.py 文件标志部分:

flags = [ 
'-std=c++11',
'-x', 'c++',
'-I', 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/include',
'-I', 'C:/Program Files (x86)/Windows Kits/10/Include/10.0.10150.0/ucrt',
'-I', 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/atlmfc/include',
'-I', 'C:/Program Files (x86)/Windows Kits/NETFXSDK/4.6/include/um',
'-I', 'C:/Program Files (x86)/Windows Kits/8.1/Include/um',
'-I', 'C:/Program Files (x86)/Windows Kits/8.1/Include/shared',
'-I', 'C:/Program Files (x86)/Windows Kits/8.1/Include/winrt',
'/link', '/LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib" /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\lib" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.10150.0\ucrt\x86" /LIBPATH:"C:\Program Files (x86)\Windows Kits\8.1\lib\winv6.3\um\x86"',
'/EHsc']

【问题讨论】:

    标签: c++ vim clang youcompleteme clang-cl


    【解决方案1】:

    micbou给了我answer这个问题。

    在 Windows 上,Clang 在 32 位上使用 i686-pc-windows-gnu,在 64 位上使用 x86_64-w64-windows-gnu 作为其默认目标。您需要通过添加以下标志将其更改为 MSVC:

    flags = [ '--target=&lt;arch&gt;-pc-windows-msvc&lt;xx.yy.zzzzz&gt;' ] 其中i686 在 32 位上,x86_64 在 64 位上,&lt;xx.yy.zzzzz&gt; 是 MSVC 的版本。您可以通过运行 VC++ 编译器cl.exe 找到它。在您的情况下,由于您在 32 位上使用 MSVC 14,因此目标应该是 i686-pc-windows-msvc19.00.23506

    使用您已经添加的包含标志,您应该从标题中获得补全。

    在我的特殊情况下,--target=x86_64-pc-windows-msvc19.00.23026 标志解决了这个问题。

    【讨论】:

      【解决方案2】:

      这与 YCM 无关,只是回答普通的方法。

      我通常在 linux 上做的是扩展 path 以包含标准库头文件,例如:

      set path+=/usr/include/**
      

      那么,我们可以使用Ctrl-pCtrl-n

      【讨论】:

        猜你喜欢
        • 2017-09-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-29
        • 2013-11-13
        • 2021-10-02
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多