Closed xiaozhidian closed 3 years ago
我已经成功解决了,不用关闭语法错误提示,解决了胡乱报错的问题。 主要是参考stackoverflow和github上的,不得不说stackoverflow和github牛逼!百度和各种博客上没有一个是真正解决这个问题的,都是相互抄袭一些没用的,唉,浪费了我两天时间。 参考链接: https://stackoverflow.com/questions/66346896/how-to-fix-ycm-printing-use-of-undeclared-identifier-cout-or-no-member-named https://github.com/ycm-core/YouCompleteMe/issues/2885#issuecomment-360835891
解决方法就是:你的 .ycm_extra_conf.py 文件里面需要配置c++版本的路径/usr/include/c++/7.2.1 要放在 /usr/include 前面!这个很重要!
可以通过 g++ --version命令查看你的g++版本,c++的include目录是在/usr/include/c++下面,根据你的版本自己找。
原文:
You are getting these errors because the order of your -isystem flags is wrong: /usr/include/c++/7.2.1 must be included before /usr/include. Try the following .ycm_extra_conf.py file:
def FlagsForFile( filename ):
return { 'flags': [
'-Wall',
'-Wextra',
'-Werror',
'-std=c++11',
'-x',
'c++',
'-isystem',
'/usr/include/c++/7.2.1',
'-isystem',
'/usr/include/c++/7.2.1/x86_64-pc-linux-gnu',
'-isystem',
'/usr/include/c++/7.2.1/backward',
'-isystem',
'/usr/local/include',
'-isystem', '/usr/include',
] }
已经成功解决了语法错误提示问题
代码如下: 1 #include
2 using namespace std;
3 int main()
4 {
✗ 5 cout<< endl;
✗ 6 cout << "hello world." << endl;
7 return 0;
8 }
代码没有问题,老是在cout前面出现红色×叉叉,也不知道怎么解决,求巨佬帮助!