-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When using json db for c++ completion headers do not compile #735
Comments
I think this is a duplicate of #303. Also, look at the current ycm_extra_conf.py in YCM; I made some changes to it recently to make it easier to get flags for headers when using the compilation db. If you based your extra conf file on old version, you might want to take some of the newer code. |
I did base it on the latest conf file. |
Well, the root of the issue is that the compilation database as produced by CMake doesn't have any flags for your header files, only source files. So you need to somehow produce flags for them. YCM's extra conf file has logic where it tries to detect whether the file that we need flags for is a header file and ask for flags for the corresponding source file instead since that would usually work. But this is not perfect and it was written to work for YCM code. In the end, you need an extra conf file with logic relevant for your project. Either ensure that your compilation database has entries for header files or come up with some mechanism for producing flags for them in the extra conf file. This is project specific; YCM works just fine if you give flags for headers. |
I'm trying to make the completion work for headers. I'm doing the trick you've suggested where I replace the file name of the header and return the flags for the cpp file.
The problem is that for some reason the compilation fails because the clang is unable to find some basic headers like
<string>
,<cstring>
, for example:"col 10 error| 'cstring' file not found"
I suspect the the reason this happens to me is because my header and cpp are not located in the same directory though when I look at the flags returned by ycm_extra_conf.py they all have absolute path. Of course I don't just change the ".h" to ".cpp" but actually finding the right ".cpp" file. Not sure how this affects the compilation but just throw it out there.
I've installed the latest YCM and Clang a week ago (for the first time) so I should be up to date.
Thanks for all the work you do!
The text was updated successfully, but these errors were encountered: