ctags 忽略 libc6、libstdc++ 的列表并提升
我将 ctags 与 vim 和 OmniCppComplete 插件一起使用。目前,在生成标签时,我为每个库单独生成标签。对于 libc6,我在名为 libc6-ignore 的文件中使用以下标记/宏列表来在处理过程中忽略:
__attribute__
__attribute_deprecated__
__attribute_format_arg__
__attribute_format_strfmon__
__attribute_malloc__
__attribute_noinline__
__attribute_pure__
__attribute_used__
__attribute_warn_unused_result__
__wur
__THROW
__nonnull+
我是否缺少任何其他我应该忽略的标记,以及在为 libstdc++ 生成标记时应该使用相同的列表还是不同的列表和提升?
对于任何感兴趣的人,我使用以下内容来生成我的标签文件:
# First make sure apt-file is install and then do:
$ sudo apt-file update
# set up tags for libc, the standard C library
$ apt-file list libc6-dev | grep -o '/usr/include/.*\.h'> ~/.vim/tags/libc6-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -I./libc6-ignore -f ~/.vim/tags/libc6 -L ~/.vim/tags/libc6-filelist
# create tags for stdlibc++ and STL
$ apt-file list libstdc++6-4.4-dev | grep -E -o '/usr/include/.*\.(h|hpp)' > ~/.vim/tags/stdlibcpp-filelist
$ ctags --sort=foldcase -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp -L ~/.vim/tags/stdlibcpp-filelist
# For Boost
$ apt-file list boost | grep -E -o '/usr/include/.*\.(h|hpp)' | grep -v '/usr/include/boost/typeof/' > ~/.vim/tags/boost-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost -L ~/.vim/tags/boost-filelist
I use ctags with vim and the OmniCppComplete plugin. Currently when generating my tags I do it individually for each library. For libc6 I use the following list of tokens / macros in a file named libc6-ignore to ignore during processing:
__attribute__
__attribute_deprecated__
__attribute_format_arg__
__attribute_format_strfmon__
__attribute_malloc__
__attribute_noinline__
__attribute_pure__
__attribute_used__
__attribute_warn_unused_result__
__wur
__THROW
__nonnull+
Am I missing any other tokens I should be ignoring and should I be using this same list or a different one when generating tags for libstdc++ and boost?
For anyone who's interested I use the following to generate my tag files:
# First make sure apt-file is install and then do:
$ sudo apt-file update
# set up tags for libc, the standard C library
$ apt-file list libc6-dev | grep -o '/usr/include/.*\.h'> ~/.vim/tags/libc6-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -I./libc6-ignore -f ~/.vim/tags/libc6 -L ~/.vim/tags/libc6-filelist
# create tags for stdlibc++ and STL
$ apt-file list libstdc++6-4.4-dev | grep -E -o '/usr/include/.*\.(h|hpp)' > ~/.vim/tags/stdlibcpp-filelist
$ ctags --sort=foldcase -R --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/stdlibcpp -L ~/.vim/tags/stdlibcpp-filelist
# For Boost
$ apt-file list boost | grep -E -o '/usr/include/.*\.(h|hpp)' | grep -v '/usr/include/boost/typeof/' > ~/.vim/tags/boost-filelist
$ ctags --sort=foldcase --c++-kinds=+p --fields=+iaS --extra=+q -f ~/.vim/tags/boost -L ~/.vim/tags/boost-filelist
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您还可以使用修改后的 libstdc++ 库:http://www.vim.org/scripts/script.php?script_id=2358" rel="nofollow">http:// /www.vim.org/scripts/script.php?script_id=2358
这包含适用于 ctags 的 C++ 头文件的精简版本。我制作了一个 Python 脚本,用于提取所有内容标签文件中以下划线开头的标签。您可以使用此脚本选择要排除的标签。
请随意定制脚本以满足您的需求或提出其他建议:
You can also use the modified libstdc++ library:http://www.vim.org/scripts/script.php?script_id=2358
This contains a stripped version of the C++ header files which works for ctags.I made a Python script that extracts all tags beginning with an underscore from a tags file. You can choose with this script which tags to exclude.
Feel free to tailor the script to meet your needs or suggest anything else:
我已按照这些说明进行操作,并且我能够使所有 boost boost 参考工作,即
我可以直接跳转到 iostream
但是我仍然缺少的是转到例如
虽然在我的生成脚本中我已包含如您所提到的即
在我生成之后每当我尝试访问 stdio.h 时,标签“libc6”文件都会显示“E426:未找到标签:stdlib”。
以下是我添加到 .vimrc 中的内容,以便使所有这 3 个标记文件可见。
我不是专家,但我可以说这对 boost 有效,但对 libc6-dev 无效。有人可以帮我解决这个问题吗?
这里的代码与上面的
sudo apt-file update相同
I have followed those instructions and I am able to get all boost boost references working i.e.
I can jump directly to iostream
However what I am still missing is to go to for example
Although in my generate script I have included as you mentioned i.e.
After i generate the tag "libc6" file whenever I try to go to stdio.h it is saying “E426: tag not found: stdlib”.
Here is what I have included additionally to my .vimrc in order to make all those 3 tag files visible.
I am not an expert however I can say that this worked somehow for boost but not for libc6-dev. Can someone assist me with the solution
here is the same code as above
sudo apt-file update
抱歉——我以前从未使用过 ctags——但我会尝试一下这个问题。
如果我理解正确的话,您可以使用 GCC 本身的关键字列表。我在
gcc/gcc/c 中找到了这个 https://gist.github.com/959484 -family/c-common.c
。看起来它包含所有 C(c/c++/obj-c 变体)的保留字。我想有些对所有编译器都有效,当然这些是针对 gcc 的。至于找出要忽略的其他符号,在 OS X 上我会使用 nm 转储相关库的符号,并将所有标记为私有的符号(例如“s”而不是“S”)添加到我的符号列表中忽略。 Linux 有类似的库转储工具吗?
希望这有用。
Sorry--I've never used ctags before--but I'll take a stab at this question.
If I understand correctly, you can use the list of keywords from GCC itself. I found this https://gist.github.com/959484 inside
gcc/gcc/c-family/c-common.c
. Looks like it includes reserved words for all the C (c/c++/obj-c variants). I guess some are valid for all compilers, these are for gcc of course.As for figuring out other symbols to ignore, on OS X I'd use nm to dump the symbols of the library in question an add all symbols marked as private ('s' instead of 'S' for example) to my list of symbols to ignore. Linux has a similar library-dumping tool?
Hope that's useful.
我有自己的清单,但从未想过添加您已经列出的内容!
这是我提出的 libc6 的更新忽略列表(Ubuntu 14.04 和 GCC 4.8.4),用作 ctags 的 -I 选项的输入:
我还创建了以下忽略列表,用于生成 libstdc++ 的标签文件( Ubuntu 14.04 上的 GCC 4.8.2)(同样,这是 -I 选项的输入):
我将
__attribute__
更改为:__attribute__+
以指示它看起来像一个函数并且应该被忽略。当然,我也为 Boost 创建了一个,但我想在有人需要之前我不会发布它。
I had my own list and never thought about adding what you've already listed!
Here's that updated ignore list for libc6 that I've come up with (Ubuntu 14.04 and GCC 4.8.4) to use as input to the -I option of ctags:
I also created the following ignore list for generating a tags file for libstdc++ (GCC 4.8.2 on Ubuntu 14.04) (again, this is input to the -I option):
I changed
__attribute__
to be:__attribute__+
to indicate it looks like a function and should be ignored.Of course, I have created one for Boost as well, but I think I'll refrain from posting it until someone has a need.