c – ctags没有正确解析stdio.h

前端之家收集整理的这篇文章主要介绍了c – ctags没有正确解析stdio.h前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试使用带有VIM的ctags,而且我是两者的新手.为了测试ctags有用的程度,我决定通过一个非常简单的测试,即解析/usr/include中的头文件,以便我可以自动完成一些非常基本的功能.

当我运行命令

ctags  --c++-kinds=+p --fields=+iaS -f ~/.tags/tags /usr/include/*.h

然后输出打印

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__,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,...)
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,int __whence)
fseeko  /usr/include/stdio.h    /^extern int fseeko (FILE *__stream,__off_t __off,int __whence)
fseeko64    /usr/include/stdio.h    /^extern int fseeko64 (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)
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)
va_list /usr/include/stdio.h    /^typedef _G_va_list va_list;$/;"   t
vdprintf    /usr/include/stdio.h    /^extern int vdprintf (int __fd,$/;"    p   signature:(int __fd,_G_va_list __arg)
vfprintf    /usr/include/stdio.h    /^extern int vfprintf (FILE *__restrict __s,$/;" p   signature:(FILE *__restrict __s,_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

很明显ctags错过了一些非常明显的函数,比如fopen,但它包含了像fclose这样的函数.当我使用ctags解析时,是否有一些我缺少的选项?

解决方法

在你的ctags命令中添加一个-I__wur,你就会得到你想要的结果.
__wur是__attribute __的一个宏((__ warn_unused_result__))

有关更详尽的解释,请参阅:

http://sourceforge.net/mailarchive/message.php?msg_name=48A7FF60.9080609%40sina.com

猜你在找的C&C++相关文章