1

Recently, I installed YouCompleteMe and I'm new user in it. I read installation instructions from this link: http://valloric.github.io/YouCompleteMe. Now, I can use it for python and etc, but I can't use it for C. I don't understand what's the meaning of this sentence from the link: "forget that if you want the C-family semantic completion engine to work, you will need to provide the compilation flags for your project to YCM." I read the YCM user guide, but I couldn't solve my problem. Tnx from anybody who explains me what is the meaning of the above sentence and what do I do?

0

You need to have a file named .ycm_extra_conf.py in the directory containing the projects source code. That link is to the example file provided with the plugin, and you have to update it to properly describe your compilation options.

I usually create one (or more) for a project and commit them along with the project into whatever scm program I'm using.

Couple of things to watch out for:

If you are used to gcc there are some compilation flags that clang (what YCM is using) doesn't support.

If you are compiling linux kernel code (driver, etc) it will not work well, since clang doesn't support many of the assembly macros provided by gcc. I'm not aware of a workaround.

Additional info from developer:

C-family Semantic Completion

YCM looks for a .ycm_extra_conf.py file in the directory of the opened file or in any directory above it in the hierarchy (recursively); when the file is found, it is loaded (only once!) as a Python module. YCM calls a FlagsForFile method in that module which should provide it with the information necessary to compile the current file. You can also provide a path to a global .ycm_extra_conf.py file, which will be used as a fallback. To prevent the execution of malicious code from a file you didn't write YCM will ask you once per .ycm_extra_conf.py if it is safe to load. This can be disabled and you can white-/blacklist files. See the Options section for more details.

See YCM's own .ycm_extra_conf.py for details on how this works. You should be able to use it as a starting point. Don't just copy/paste that file somewhere and expect things to magically work; your project needs different flags. Hint: just replace the strings in the flags variable with compilation flags necessary for your project. That should be enough for 99% of projects.

If you've modified and added this file to your project (or provided a path to it) you will not get the same error message as in your original question. If you do, YCM can't see it - possibly named incorrectly ( leading . ) or not in the right level in the source hierarchy - see link above.

Otherwise if its still not working you should have a different error message; post that. Initial YCM configuration takes some work and took a few trips through their documentation the first time.

1
  • Tnx but it doesn't work for me.
    – ThisIsMe
    Aug 14 '16 at 20:34
0

I don't understand what's the meaning of this sentence from the link: "forget that if you want the C-family semantic completion engine to work, you will need to provide the compilation flags for your project to YCM."

This simply means that instad of compiling like

cd ~/.vim/bundle/YouCompleteMe ./install.py You need to add

cd ~/.vim/bundle/YouCompleteMe ./install.py --clang-completer

I think the install instructions are updated anyway to reflect the above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.