怎样用ctags为glibc的头文件生成tags?
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
-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...
使用tags文件时,需要在tags所在的目录打开vim。
不同目录时需要在vim里设置tags变量,变量值为tags文件路径。例如: