Vim YouCompleteMe Mac OS C family 系统库函数不能自动补全

之前还好好的,升级Xcode 和 command tools 后突然发现 YouCompleteMe 不能对c 语言库函数(printf 等)自动补全了,以及出现对 NULL 等 宏定义提示未定义等情况,折腾了一上午,各种搜索,最终还是在官方文档上找到了答案,在此记录一下, 也希望能帮助其他遇到这个问题的人。

  1. 确认.ycm_extra_conf.py 路径时候配对了:
    • let g:ycm_global_ycm_extra_conf=’/your_path/.ycm_extra_conf.py’
  2. 确认 .ycm_extra_conf.py路径配置没有问题,那么再检查一下.ycm_extra_conf.py文件内容时候有问题(因为有时候不小心按了一下键盘导致内容发生改变,我就翻过一次这样错误,在flags 列表里面添加path 的时候少些了一个逗号,导致自动补全失败,最好的方式就是和官方最新的文件用对比工具比较一下,看看时候有改动)
  3. 如果以上问题都确认,并排除,那试试官方给出的方法,也就是今遇到问题的解决方法:
    Completion doesn’t work with the C++ standard library headers

    This is caused by an issue with libclang that only affects some operating systems. Compiling with clang the binary will use the correct default header search paths but compiling with libclang.so (which YCM uses) does not.

    Mac OS X is normally affected, but there’s a workaround in YCM for that specific OS. If you’re not running that OS but still have the same problem, continue reading.

    The workaround is to call echo | clang -v -E -x c++ - and look at the paths under the #include <…> search starts here: heading. You should take those paths, prepend -isystem to each individual path and append them all to the list of flags you return from your FlagsForFile function in your .ycm_extra_conf.py file.

    在terminal 里面输入: echo | clang -v -E -x c++ - :
    这里写图片描述

    把红框里面的的路径全部添加的.ycm_extra_conf.py 的 flag 列表里面:
    这里写图片描述

    注意:最后一行是以逗号 , 结尾的.

  4. 最后:不管遇到什么问题查阅官方文档可能是快的解决问题方式

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

皮克桃在写代码

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值