c++ - mac系统下用带YouCompleteMe插件的vim编写cpp程序报错

【字号: 日期:2023-06-02浏览:26作者:雯心

问题描述

c++ - mac系统下用带YouCompleteMe插件的vim编写cpp程序报错

黄色三角形显示:expression result unused;红色叉叉显示:reference to overloaded function could not be resolved;did you mean to call it?

下面是我的.ycm_extra_conf.py配置

c++ - mac系统下用带YouCompleteMe插件的vim编写cpp程序报错

问题解答

回答1:

不好意思自己的头文件位置找错了,不应该用网上帮你配制或者是默认的,具体的头文件位置还是要自己配制!倒数第五行替换换成下列’/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include’

回答2:

运行 echo | clang -std=c++11 -stdlib=libc++ -v -E -x c++ - 找到系统的头文件,加入-isystem里面。如果你用了homebrew安装了各种包的话,也需要把include加入-isystem里面,应该是’/usr/local/include’,。我的ycm_config里面是这样的

53 ’c++’, 54 ’-isystem’, #Mark as system header 55 #Using `echo | clang -std=c++11 -stdlib=libc++ -v -E -x c++ -` to generate the following infos 56 ’/usr/local/include’, 57 ’-isystem’, 58 ’/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1’, 59 ’-isystem’, 60 ’/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/7.0.0/include’, 61 ’-isystem’, 62 ’/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include’, 63 ’-isystem’, 64 ’/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include’, 65 ’-isystem’, 66 ’/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks’,

相关文章: