我在 vim 和 OmniCppComplete 中使用 ctags插入。目前,在生成我的标签时,我会为每个库单独执行此操作。对于 libc6,我在一个名为 libc6-ignore 的文件中使用以下 token /宏列表,以便在处理期间忽略:
__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++ 和 boost 生成标签时,我是否遗漏了我应该忽略的任何其他标记?应该使用相同的列表还是不同的列表?
对于任何感兴趣的人,我使用以下内容来生成我的标签文件:
# 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
最佳答案
也可以使用修改后的libstdc++库:
http://www.vim.org/scripts/script.php?script_id=2358
这包含适用于 ctags 的 C++ 头文件的剥离版本。
我制作了一个 Python 脚本,它从标签文件中提取所有以下划线开头的标签。您可以使用此脚本选择要排除的标签。 随意定制脚本以满足您的需求或提出其他建议:
import re
tags=open('tags','r')
output=open('exclude','w')
regex=re.compile('^_[a-zA-Z0-9_]*')
results=set()
for line in tags:
result=regex.match(line)
if(result!=None):
results.add(result.group(0))
tags.close()
for element in sorted(results):
output.write('{0}\n'.format(element))
output.close()
关于c++ - ctags 忽略 libc6、libstdc++ 和 boost 的列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5626188/