I am trying to use ctags with VIM, and I am a newbie to both. In order to test the extent to which ctags could be useful I decided to put it through a very simple test, namely to parse the headers in /usr/include so that I could autocomplete some very basic functions.
When I run the command
ctags --c++-kinds=+p --fields=+iaS -f ~/.tags/tags /usr/include/*.h
then the output prints
BUFSIZ /usr/include/stdio.h 108;" d
EOF /usr/include/stdio.h 115;" d
FILE /usr/include/stdio.h /^typedef struct _IO_FILE FILE;$/;" t typeref:struct:_IO_FILE
FSETLOCKING_BYCALLER /usr/include/stdio_ext.h /^ FSETLOCKING_BYCALLER$/;" e enum:__anon122
FSETLOCKING_BYCALLER /usr/include/stdio_ext.h 39;" d
FSETLOCKING_INTERNAL /usr/include/stdio_ext.h /^ FSETLOCKING_INTERNAL,$/;" e enum:__anon122
FSETLOCKING_INTERNAL /usr/include/stdio_ext.h 36;" d
FSETLOCKING_QUERY /usr/include/stdio_ext.h /^ FSETLOCKING_QUERY = 0,$/;" e enum:__anon122
FSETLOCKING_QUERY /usr/include/stdio_ext.h 32;" d
P_tmpdir /usr/include/stdio.h 128;" d
SEEK_CUR /usr/include/stdio.h 122;" d
SEEK_END /usr/include/stdio.h 123;" d
SEEK_SET /usr/include/stdio.h 121;" d
_IOFBF /usr/include/stdio.h 101;" d
_IOLBF /usr/include/stdio.h 102;" d
_IONBF /usr/include/stdio.h 103;" d
_IO_STDIO /usr/include/libio.h 165;" d
_IO_STDIO_H /usr/include/libio.h 30;" d
_OLD_STDIO_MAGIC /usr/include/libio.h 121;" d
_STDIO_EXT_H /usr/include/stdio_ext.h 24;" d
_STDIO_H /usr/include/stdio.h 27;" d
_STDIO_USES_IOSTREAM /usr/include/stdio.h 73;" d
_VA_LIST_DEFINED /usr/include/stdio.h 81;" d
__FILE /usr/include/stdio.h /^typedef struct _IO_FILE __FILE;$/;" t typeref:struct:_IO_FILE
__FILE_defined /usr/include/stdio.h 57;" d
____FILE_defined /usr/include/stdio.h 67;" d
__need_FILE /usr/include/stdio.h 37;" d
__need_FILE /usr/include/stdio.h 59;" d
__need_NULL /usr/include/stdio.h 33;" d
__need___FILE /usr/include/stdio.h 38;" d
__need___FILE /usr/include/stdio.h 69;" d
__need_getopt /usr/include/stdio.h 902;" d
__need_size_t /usr/include/stdio.h 32;" d
__wur /usr/include/stdio.h /^ _IO_cookie_io_functions_t __io_funcs) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^ __THROW __attribute__ ((__format__ (__printf__, 2, 0))) __wur;$/;" v
__wur /usr/include/stdio.h /^ __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;$/;" v
__wur /usr/include/stdio.h /^ __THROW __attribute_malloc__ __wur;$/;" v
__wur /usr/include/stdio.h /^ __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern char *tmpnam (char *__s) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern char *tmpnam_r (char *__s) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int feof (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int feof_unlocked (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int ferror (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int ferror_unlocked (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int fileno (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int fileno_unlocked (FILE *__stream) __THROW __wur;$/;" v
__wur /usr/include/stdio.h /^extern int ftrylockfile (FILE *__stream) __THROW __wur;$/;" v
_flushlbf /usr/include/stdio_ext.h /^extern void _flushlbf (void);$/;" p signature:(void)
cuserid /usr/include/stdio.h /^extern char *cuserid (char *__s);$/;" p signature:(char *__s)
dprintf /usr/include/stdio.h /^extern int dprintf (int __fd, __const char *__restrict __fmt, ...)$/;" p signature:(int __fd, __const char *__restrict __fmt, ...)
fclose /usr/include/stdio.h /^extern int fclose (FILE *__stream);$/;" p signature:(FILE *__stream)
fcloseall /usr/include/stdio.h /^extern int fcloseall (void);$/;" p signature:(void)
fflush /usr/include/stdio.h /^extern int fflush (FILE *__stream);$/;" p signature:(FILE *__stream)
fflush_unlocked /usr/include/stdio.h /^extern int fflush_unlocked (FILE *__stream);$/;" p signature:(FILE *__stream)
fgetc /usr/include/stdio.h /^extern int fgetc (FILE *__stream);$/;" p signature:(FILE *__stream)
fgetc_unlocked /usr/include/stdio.h /^extern int fgetc_unlocked (FILE *__stream);$/;" p signature:(FILE *__stream)
fgetpos /usr/include/stdio.h /^extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);$/;" p signature:(FILE *__restrict __stream, fpos_t *__restrict __pos)
fgetpos64 /usr/include/stdio.h /^extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);$/;" p signature:(FILE *__restrict __stream, fpos64_t *__restrict __pos)
fpos64_t /usr/include/stdio.h /^typedef _G_fpos64_t fpos64_t;$/;" t
fpos_t /usr/include/stdio.h /^typedef _G_fpos_t fpos_t;$/;" t
fprintf /usr/include/stdio.h /^extern int fprintf (FILE *__restrict __stream,$/;" p signature:(FILE *__restrict __stream, __const char *__restrict __format, ...)
fputc /usr/include/stdio.h /^extern int fputc (int __c, FILE *__stream);$/;" p signature:(int __c, FILE *__stream)
fputc_unlocked /usr/include/stdio.h /^extern int fputc_unlocked (int __c, FILE *__stream);$/;" p signature:(int __c, FILE *__stream)
fputs /usr/include/stdio.h /^extern int fputs (__const char *__restrict __s, FILE *__restrict __stream);$/;" p signature:(__const char *__restrict __s, FILE *__restrict __stream)
fputs_unlocked /usr/include/stdio.h /^extern int fputs_unlocked (__const char *__restrict __s,$/;" p signature:(__const char *__restrict __s, FILE *__restrict __stream)
fscanf /usr/include/stdio.h 441;" d
fseek /usr/include/stdio.h /^extern int fseek (FILE *__stream, long int __off, int __whence);$/;" p signature:(FILE *__stream, long int __off, int __whence)
fseeko /usr/include/stdio.h /^extern int fseeko (FILE *__stream, __off_t __off, int __whence);$/;" p signature:(FILE *__stream, __off_t __off, int __whence)
fseeko64 /usr/include/stdio.h /^extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);$/;" p signature:(FILE *__stream, __off64_t __off, int __whence)
fsetpos /usr/include/stdio.h /^extern int fsetpos (FILE *__stream, __const fpos_t *__pos);$/;" p signature:(FILE *__stream, __const fpos_t *__pos)
fsetpos64 /usr/include/stdio.h /^extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos);$/;" p signature:(FILE *__stream, __const fpos64_t *__pos)
getc /usr/include/stdio.h /^extern int getc (FILE *__stream);$/;" p signature:(FILE *__stream)
getc /usr/include/stdio.h 527;" d
getc_unlocked /usr/include/stdio.h /^extern int getc_unlocked (FILE *__stream);$/;" p signature:(FILE *__stream)
getchar /usr/include/stdio.h /^extern int getchar (void);$/;" p signature:(void)
getchar_unlocked /usr/include/stdio.h /^extern int getchar_unlocked (void);$/;" p signature:(void)
getw /usr/include/stdio.h /^extern int getw (FILE *__stream);$/;" p signature:(FILE *__stream)
jpeg_stdio_dest /usr/include/jpeglib.h /^EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile));$/;" p signature:(j_compress_ptr cinfo, FILE * outfile)
jpeg_stdio_dest /usr/include/jpeglib.h 841;" d
jpeg_stdio_src /usr/include/jpeglib.h /^EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile));$/;" p signature:(j_decompress_ptr cinfo, FILE * infile)
jpeg_stdio_src /usr/include/jpeglib.h 842;" d
pclose /usr/include/stdio.h /^extern int pclose (FILE *__stream);$/;" p signature:(FILE *__stream)
perror /usr/include/stdio.h /^extern void perror (__const char *__s);$/;" p signature:(__const char *__s)
printf /usr/include/stdio.h /^extern int printf (__const char *__restrict __format, ...);$/;" p signature:(__const char *__restrict __format, ...)
putc /usr/include/stdio.h /^extern int putc (int __c, FILE *__stream);$/;" p signature:(int __c, FILE *__stream)
putc /usr/include/stdio.h 569;" d
putc_unlocked /usr/include/stdio.h /^extern int putc_unlocked (int __c, FILE *__stream);$/;" p signature:(int __c, FILE *__stream)
putchar /usr/include/stdio.h /^extern int putchar (int __c);$/;" p signature:(int __c)
putchar_unlocked /usr/include/stdio.h /^extern int putchar_unlocked (int __c);$/;" p signature:(int __c)
puts /usr/include/stdio.h /^extern int puts (__const char *__s);$/;" p signature:(__const char *__s)
putw /usr/include/stdio.h /^extern int putw (int __w, FILE *__stream);$/;" p signature:(int __w, FILE *__stream)
rewind /usr/include/stdio.h /^extern void rewind (FILE *__stream);$/;" p signature:(FILE *__stream)
scanf /usr/include/stdio.h 442;" d
sscanf /usr/include/stdio.h 443;" d
stderr /usr/include/stdio.h 152;" d
stdin /usr/include/stdio.h 150;" d
stdout /usr/include/stdio.h 151;" d
ungetc /usr/include/stdio.h /^extern int ungetc (int __c, FILE *__stream);$/;" p signature:(int __c, FILE *__stream)
va_list /usr/include/stdio.h /^typedef _G_va_list va_list;$/;" t
vdprintf /usr/include/stdio.h /^extern int vdprintf (int __fd, __const char *__restrict __fmt,$/;" p signature:(int __fd, __const char *__restrict __fmt, _G_va_list __arg)
vfprintf /usr/include/stdio.h /^extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,$/;" p signature:(FILE *__restrict __s, __const char *__restrict __format, _G_va_list __arg)
vfscanf /usr/include/stdio.h 500;" d
vprintf /usr/include/stdio.h /^extern int vprintf (__const char *__restrict __format, _G_va_list __arg);$/;" p signature:(__const char *__restrict __format, _G_va_list __arg)
vscanf /usr/include/stdio.h 501;" d
vsscanf /usr/include/stdio.h 502;" d
so clearly ctags missed some very obvious functions like fopen, yet it included functions like fclose. Is there some option I am missing when I am parsing with ctags?
Answer
Add a -I__wur
to your ctags command and you'll get the result you're after.__wur
is a macro for __attribute__ ((__warn_unused_result__))
For a more thurough explanation, see:
http://sourceforge.net/mailarchive/message.php?msg_name=48A7FF60.9080609%40sina.com
No comments:
Post a Comment