tags:

views:

62

answers:

2

I'm trying to generate tags for the C Standard Lib using Exuberant Ctags 5.8, however it seems that the headers are not parsed completely... For example, when I generate the tags for /usr/include/string.h, I get this:

!_TAG_FILE_FORMAT   2   /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED   1   /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR    Darren Hiebert  /[email protected]/
!_TAG_PROGRAM_NAME  Exuberant Ctags //
!_TAG_PROGRAM_URL   http://ctags.sourceforge.net    /official site/
!_TAG_PROGRAM_VERSION   5.8 //
NULL    /usr/include/string.h   /^#define NULL /;"  d
_SIZE_T /usr/include/string.h   /^#define   _SIZE_T$/;" d
_SSIZE_T    /usr/include/string.h   /^#define _SSIZE_T$/;"  d
_STRING_H_  /usr/include/string.h   /^#define   _STRING_H_$/;"  d
size_t  /usr/include/string.h   /^typedef   __darwin_size_t     size_t;$/;" t
ssize_t /usr/include/string.h   /^typedef __darwin_ssize_t  ssize_t;$/;"    t
strerror    /usr/include/string.h   /^char  *strerror(int) __DARWIN_ALIAS(strerror);$/;"    v

Obviously, a lot of functions are missing (strcpy, strlen, strcmp, etc..) Here's a link to the actual header file: http://pastie.org/private/lvgvtg1lmzaenidg0rvq

I just ran ctags /usr/include/string.h Am I doing something wrong? Any help would be appreciated...

+1  A: 

I found some relevant information here: http://www.mail-archive.com/[email protected]/msg210327.html

Notably:

ctags does not generate tags for function prototypes by default, only for the actual function definitions. See the documentation for the ---kinds option in ctags(1)

So it turns out I have to add the --c-kinds=+p flag for it to parse function prototypes. I'm not sure why it doesn't parse prototypes by default?

silvertab
+2  A: 

I believe that ctags doesn't include function prototypes by default, only function implementations.

If you call it as ctags --c-kinds=+px /usr/include/string.h, does that get you the declarations as well?

(According to the manual page here, you can call ctags −−list−kinds=c to find out what you can get ctags to output.)

Pat Wallace
Thanks for your answer! We answered pretty much at the same time so I picked yours as the Accepted Answer since it was more detailed!
silvertab