C++ - YouCompleteMe, Header Files - Stack Overflow
C++ - YouCompleteMe, Header Files - Stack Overflow
Listen
now
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
7 header file, can can I modify my .ycm_extra_conf.py file to have clang know about the additional
header files it needs?
C.cc
4
#include "A.h"
#include "B.h"
A.h
class A {};
B.h
class B : 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.
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.
c++ vim
1 What does your last sentence mean? – sehe Jun 26 '14 at 22:14
Hi sehe, I've updated the comment to more clearly explain the issue. Thanks! – archgoon Jun 27 '14 at
18:59
1 Answer
In your .ycm_extra_conf.py add your regular preprocessor flags, e.g.:
7 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',
]