why youcomplete produce error in the std::cout<<"haha"<<std::endl; and std::cout<<1<<std::endl; case

245 views
Skip to first unread message

chaowen guo

unread,
Aug 8, 2016, 5:54:19 PM8/8/16
to ycm-users
Hi:

I use ubuntu 16.04 and its own vim-youcompleteme package. Then I write a most simple case:
 
#include<iostream>

int main()
{
  std::cout<<"haha"<<std::endl;
}

youcompleteme says there is an error in std::cout<<"haha", that is invalid operands to binary expression ('ostream' (aka 'int') and 'const char *')

another example

#include<iostream>

int main()
{
  std::cout<<1<<std::endl;
}

youcompleteme says there is an error in std::endl, that is reference to overloaded function could not be resolved; did you mean to call it?

Both of the case can be compiled in g++-6 and clang++(clang3.8), because there is such error I can not use YcmCompleter GoTo to jump the definition of identifier of my cpp code if it contains std::cout or std::endl, that is one of the most important feature I need. YcmCompleter just said RuntimeError: Can't jump to definition or declaration. Any help to fix the problem?

mbo...@gmail.com

unread,
Aug 8, 2016, 7:16:48 PM8/8/16
to ycm-users
You need to add this flag to your .ycm_extra_conf.py file:

-isystem /usr/lib/llvm-3.8/lib/clang/3.8.0/include

I found the path by using the command line:

clang -v -E -x c++ -

This command prints at the end a list of system paths automatically included by the clang binary. The Vim command :YcmDiags also helped.

Note that this issue does not happen when building YCM from source.
Reply all
Reply to author
Forward
0 new messages