2

I have simple question today. I'm using this vim config - https://github.com/gergap/vim

The problem is with clang completion. It works but when I want to add more includes to get better completion then nothing is happening - it won't detect new headers.

Get #include <sys/types.h> for example. This is what I've added to .clang_complete file placed in directory where my main.c is placed:

-I/usr/include/x86_64-linux-gnu/sys/

which I found by invoking

find /usr/include/ -name types.h

What can be wrong? Could you show me some working .clang_complete files with includes to unix headers? Maybe I'll find problem in that way.

This is the output from gcc with -v flag:

 /usr/lib/gcc/x86_64-linux-gnu/4.8/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
python
  • 198
  • 1
  • 5
  • 13
  • Path inside `<>` or `""` is *appended* to every include directory you pass to compiler. So if you wan't ``, compiler will check if `/usr/include/x86_64-linux-gnu/sys/sys/types.h` exists. Try using `-I/usr/include/x86_64-linux-gnu/`. – xaizek Nov 11 '14 at 07:15
  • @xaizek To be clear. Do I need to compile my programs with clang to make it work? Or compile just once after I added new path? – python Nov 11 '14 at 08:23
  • you don't need to compile anything to make it work, but I'd suggest restarting Vim after adding new lines to `.clang_complete`, just to be sure it's reloaded (at least this time). I mentioned compiler as completion processes arguments the same way compiler would do, so just put `-I/usr/include/x86_64-linux-gnu/` to your `.clang_complete`, restart Vim and it should work. – xaizek Nov 12 '14 at 07:31

1 Answers1

0

To investigate, run your gcc (or clang) with the -v option. This will display the search path used while compiling. On my system (FreeBSD) a simple compile without -I options prints

#include "..." search starts here:
#include <...> search starts here:
 /usr/include/clang/3.4.1
 /usr/include
End of search list.

That should give you an idea what directories to add to .clang_complete. Important: order matters!

Jens
  • 69,818
  • 15
  • 125
  • 179
  • I've edited my question with output from gcc -v, but I still don't know how this is related to my problem with adding `/usr/include/x86_64-linux-gnu/sys/` path to clang complete :) – python Nov 10 '14 at 22:22