YouCompleteMe,头文件 [英] YouCompleteMe, header files

查看:76
本文介绍了YouCompleteMe,头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用YouCompleteMe处理某些C ++头文件.头文件不包括查找所有正在使用的类所需的所有其他头文件.无需修改头文件,是否可以修改.ycm_extra_conf.py文件以让clang知道其需要的其他头文件?

I am working with some C++ header files using YouCompleteMe. The header file does not include all the other header files that it needs in order to find all the classes it is using. Without modifying the header file, can can I modify my .ycm_extra_conf.py file to have clang know about the additional header files it needs?

作为一个例子,假设我有三个文件"A.h","B.h"和"C.cc".

As an example, suppose I have three files "A.h", "B.h", and "C.cc".

C.cc

#include "A.h"
#include "B.h"

A.h

class A {};

B.h

class B : A {};

B包含文件无法自行编译,但是C.cc将正确编译,因为它以正确的顺序包含了所有内容.但是,如果我自己打开B.h,它将抱怨A未被定义.

The B include file cannot compile on it's own, but C.cc will compile correctly because it includes things in the right order. However, if I open B.h on it's own, it will complain about A not being defined.

我知道C.cc可以正确编译,因此,当打开B.h在与C.cc使用的上下文相同的上下文中打开B.h时,如何告诉YCM?标记似乎不足以告诉YCM如何编译该文件,因为它需要使用C.cc进行编译.

I know that C.cc compiles correctly, so how do I tell YCM when opening B.h to compile it in the same context it would use for C.cc? Flags seem to be insufficient to tell YCM how to compile the file, as it needs to be compiled with C.cc.

推荐答案

在您的 .ycm_extra_conf.py 中添加常规预处理程序标志,例如:

In your .ycm_extra_conf.py add your regular preprocessor flags, e.g.:

flags = [
'-Wall',
'-Wextra',
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
'-DUNIT_TESTS',
'-std=c++11',
'-x', 'c++',
'-isystem', '/home/sehe/custom/boost',
'-isystem', '/usr/lib/gcc/x86_64-linux-gnu/4.8/include',
'-I', 'src',
'-I', 'include',
'-isystem', '/usr/include',
'-isystem', '/usr/local/include',
]

这篇关于YouCompleteMe,头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆