"Vim Environment Configuration" solves the problem of auto-completion failure caused by improper configuration of Youcompleteme plugin on Ubuntu

Source: Internet
Author: User

background :

Because of the irresistible reason, the learning environment was turned into an Ubuntu machine on a previous CentOS machine. Therefore, it is necessary to reconfigure the VIM environment on the new Ubuntu machine. It's already the third time you've configured the VIM environment (once on your Mac, once on CentOS, and on Ubuntu again ). This configuration is generally smooth, or the use of the previous log method (http://www.cnblogs.com/xbf9xbf/p/4860484.html), with pathogen management plug-in, and this time the Ubuntu machine can be networked, It's a lot easier than before without a network on CentOS.

Among them, a slightly more difficult plug-in is Youcompleteme (YCM) plug-in. Before the ycm of the Pit (http://www.cnblogs.com/xbf9xbf/p/4876306.html), this time again encountered some new problems.

Questions :

YCM needs to be able to install in native editing, this process is done with reference to the previous one. ( Download the Ubuntu version of the CLANG+LLVM precompiled file, compile Ycm,install Note to join the--clang-completer to support c-family smantic). However, in the case of a. c file, I encountered some ycm.

Simply put, the problem is: when you edit the. c file with Vim, YCM can complement the structure of the user define, but it cannot complement the struct ADDRINFO system structure in the <netdb.h>.

A structure that complements the user defined:

  

Cannot complement the struct addrinfo struct in <netdb.h>:

  

Solution:

This problem has now been solved, documenting some of the logical trajectory of the problem at the time to learn from the experience.

  Idea One: YCM's compilation process is out of the question.

YCM compilation process is really true: the support phenomenon has (1) YCM compilation process without error (2) Vim ycm can complement the structure of the user define.

YCM compile process is really wrong: the reason for conjecture (1) may be a variety of CLANG+LLVM version of the problem, followed by 3.7 recompile also rice problems (2) Ubuntu system problems

If that's true, then you don't have to think about the compile process, and if it's really wrong, it's implementation with the compiler version and the system. I grasp.

Therefore, this idea concludes that the solution must pass this aspect.

  Idea two: YCM configuration out of the question.

I thought it was. ycm_extra_conf.py configuration is a problem: the main focus in the flags option of '-isystem ', is not included in the include?

This looked for a long time, and did not have any real gains. It was a pass.

idea Three: Ubuntu system netdb.h file Problems .

The same code can be made up on my Mac and the original CentOS, but I can't make it all up on Ubuntu. A major variable is the Netdb.h file.

Perhaps there is no such struct addrinfo in netdb.h? Vi/usr/include/netdb.h Look, there is a structure. PASS.

  idea Four: The issue of file access rights .

It is possible that my code does not have permission to access netdb.h. sudo chmod after 777, still does not seem to be the issue of permissions.

Directly put the/usr/include/netdb.h file in the same directory as the project file, the. c file directly include "Netdb.h".

This does not exist file and folder permissions problem, the result is still tragic, unable to complete.

The above four ideas are negative, some helpless.

  finally put a big move, directly on the Mac/usr/include/netdb.h Direct SCP to Ubuntu project files in the same directory,. c files or # include "Netdb.h".

After doing this, YCM can finally fill out the struct addrinfo member of this struct ~

In this way, the problem must be on Ubuntu/usr/include/netdb.h this file, and then look back to the file of the struct Addrinfo part:

  

And the/usr/include/netdb.h file on Mac is the first off part of the following:

  

Yes, the production of the two is a part of the red box #ifdef __USE_POSIX

  to this, the basic can be determined, is because more ifidef, resulting in the ycm of the completion of the mechanism directly leaked over the struct ADDRINFO this structure .

But there is a contradictory thing: since the ycm complement mechanism to this strut addrinfo missed, why on Ubuntu with GCC compiled linked program can also correctly execute the results? The proof was that YCM had leaked the struct addrinfo, but GCC was missing.

Again, ycm backstage with the clang compiler-related content, not gcc. Since the Ubuntu file can be correctly compiled by GCC link, you can determine, or the problem is in the YCM configuration itself. However, this goes back to the previous idea two, there seems to be no way out.

It is also accidental that I can try to complement another structure. The structural body in the test/usr/include/netinet/in.h, incredibly able to ycm complement the member variables:

  

This proves that the YCM compiler must be no problem, the problem must be in the YCM configuration, and with Idef __use_posix.

So, out of the way to solve the problem: direct Google "Ubuntu #ifdef __use_posix":

Http://stackoverflow.com/questions/12024703/why-cant-getaddrinfo-be-found-when-compiling-with-gcc-and-std-c99

  through this post, know that the problem is in the. ycm_extra_conf.py configuration file-std=c99 This above, instead of gnu99, the problem is solved .

  

The problem is probably solved.

In short,-std=c99 is the standard C, if this is fed to the clang configuration, then clang will ignore the definition of "#ifdef __use_posix", because it belongs to C extension, does not belong to C99 category; The gnu99 is OK. The funny thing is, Clang's default-std is gnu99, the result here I superfluous, led to the various problems behind.

In this view, the default option for the GCC compiler is-std=gnu99, at least some C extrension are supported. Otherwise, the program will not be able to execute the results correctly, GCC compiled the link process is an error.

If you want to know more about the C standard and compiler problems, you can look at this log:

http://www.crifan.com/summary_c_language_version_c89_amd1_c99_c11/

  

Another, ycm automatic grammar check temporarily some in the way, turn off the method to check: Http://stackoverflow.com/questions/24500281/youcompleteme-and-syntastic-compatibility.

"Vim Environment Configuration" solves the problem of auto-completion failure caused by improper configuration of Youcompleteme plugin on Ubuntu

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.