怎样用ctags为glibc的头文件生成tags?

发布于 2022-08-24 13:30:57 字数 1260 浏览 11 评论 0

what i want:

想要在vim中用omnicompletion或者omnicppcompletion的功能,实现对glibc函数的自动补齐,比如在C源文件中输入pri,然后按C-x C-o能够弹出列表补齐printf,诸如此类。
现在的问题是,我用ctags对glibc-headers-2.15-57.fc17.i686安装的标准C头文件进行处理,生成tags_glibc文件。但是在C源文件中输入pri,然后C-x C-o,弹出的菜单里面,只有stdio2.h中的printf的定义和原型声明,而没有stdio.h的printf声明。令人奇怪的是,我用vim查看生成的tags文件,搜索printf,发现有如下三条entry:

printf	/usr/include/bits/stdio2.h	/^printf (__const char *__restrict __fmt, ...)$/;"	f
printf	/usr/include/bits/stdio2.h	108;"	d
printf	/usr/include/stdio.h	/^extern int printf (__const char *__restrict __format, ...);$/;"	p

最后一条表明ctags的确生成stdio.h中的printf的原型声明(类型为p),但是为什么我在insert模式下,输入pri<C-x C-o>,却看不见第三条呢?我错在哪里了??
fprintf(stdio.h,stdio2.h中都有该符号),memcpy(string.h,string3.h中都有)等函数也出现了同样的现象。

环境

我的系统是fedora17(3.6.3-1.fc17.i686),ctags是最新版,5.8的
用的ctags命令如下:

ctags --langmap=c:.c.h --language-force=c -h .h --c-kinds=+pxl  --exclude='tags*' --exclude='*swp' --exclude='*~' --exclude='*[!ch]' -I _THROW -I __attribute__+ -I __wur -f tags_glibc -L glibc-headers-filelist.txt 

其中,glibc-headers-filelist.txt的生成是如下命令:

rpm -ql glibc-headers |grep '\.h' >glibc-headers-filelist.txt

问题

各位vim高手,请问有没有办法能够比较好地生成glibc头文件的tags文件

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

请你别敷衍 2022-08-31 13:30:57

-e
Include extern tags. ctags will normally ignore extern declarations of functions or variables; that's handy when generating tags for your own programs. A tags file for the extern declarations in the system's standard header files can be a very handy resource, so this -e flag was created.

From http://elvis.the-little-red-haired-gi...

≈。彩虹 2022-08-31 13:30:57

使用tags文件时,需要在tags所在的目录打开vim。

不同目录时需要在vim里设置tags变量,变量值为tags文件路径。例如:

:set tags=....../tags_glibc
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文