I am trying to create a target in my Makefile to automatically create a tags
file using ctags.
I have a list of source files (.cpp files) but I don't have a list of all the header files (I use g++ -MM
to create the list of header dependencies).
I would have assumed that ctags would follow any #include
directives in the .cpp files when generating the tags, but it seems my assumption is wrong.
If I create a simple tags file like this:
ctags --fields=+iaS --extra=+q myClass.cpp
and then go into vim and type in the name of an object followed by a '.' I get the error "Pattern not found".
However, if I compile the tags file like this:
ctags --fields=+iaS --extra=+q myClass.cpp myClass.h
and do the same thing in vim I get a lovely auto-completed list of member variables/functions.
The first line in my 'myClass.cpp' file is
#include "myClass.h"
So why doesn't ctags use that to parse the header file too?
ctags -R .
option. It's a shame, I was hoping for a--follow-includes
option (maybe coupled with a--include-depth=X
option). But like you say, the ability to have conditional#include
s makes this tricky. – Misquote