ctags 找不到一个函数

ctags doesn't find one function

我克隆了 fresh gnulib(git://git.savannah.gnu.org/gnulib.git,最后更改时间:2017 年 3 月 23 日)并为所有文件编制了索引通过 ctags (Exuberant Ctags 5.9~svn20110310):

ctags -R gnulib

令人惊讶的是,我没有通过 grep 找到 full_write 函数的任何标签(我对这个函数特别感兴趣)

grep full_write tags

但是这个函数是在gnulib/lib/full-write.h

中声明的
extern size_t full_write (int fd, const void *buf, size_t count);

以及在 gnulib/lib/full-write.c

中重新定义
# define full_rw full_write

所以我真的很困惑:为什么 ctags 没有识别这个特定的函数?

ctags看声明,但可以有很多声明。但它看不到任何定义,因为真正的定义看起来像名为 full_rw 的 C 函数的定义: http://git.savannah.gnu.org/cgit/gnulib.git/tree/lib/full-write.c?id=683b6078961f10905baba598c469402ed0133425#n51

#ifdef FULL_READ
..
# define full_rw full_read
#else
...
# define full_rw full_write
#endif
size_t
full_rw (int fd, const void *buf, size_t count)

ctags 没有完整的 c 预处理功能(只有几个带有 -I 选项的预处理启发式方法,记录在 http://ctags.sourceforge.net/ctags.html). So ctags can't realize that this full_rw function definition defines something other, the full_write function. There is section of ctags documentation:

CAVEATS

Because ctags is neither a preprocessor nor a compiler, use of preprocessor macros can fool ctags into either missing tags or improperly generating inappropriate tags. Although ctags has been designed to handle certain common cases, this is the single biggest cause of reported problems. In particular, the use of preprocessor constructs which alter the textual syntax of C can fool ctags. You can work around many such problems by using the −I option.

要捕获声明,请使用 --C--kinds=+p 选项。

[jet@localhost ~]$ git clone git://git.savannah.gnu.org/gnulib.git

Cloning into 'gnulib'...
remote: Counting objects: 174685, done.        
remote: Compressing objects: 100% (24750/24750), done.        
remote: Total 174685 (delta 149911), reused 174636 (delta 149876)        
Receiving objects: 100% (174685/174685), 33.95 MiB | 3.97 MiB/s, done.
Resolving deltas: 100% (149911/149911), done.
Checking connectivity... done.
[jet@localhost gnulib]$ ctags --C-kinds=+p -R
[jet@localhost gnulib]$ grep  full_write tags
full_write  lib/full-write.h    /^extern size_t full_write (int fd, const void *buf, size_t count);$/;" p