Rob*_*nes 25 c c++ linux vim ctags
我使用带有vim的ctags和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+
Run Code Online (Sandbox Code Playgroud)
我错过了我应该忽略的任何其他令牌,在为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
Run Code Online (Sandbox Code Playgroud)
抱歉——我以前从未使用过 ctags——但我会尝试回答这个问题。
如果我理解正确的话,您可以使用 GCC 本身的关键字列表。我在里面找到了这个https://gist.github.com/959484gcc/gcc/c-family/c-common.c。看起来它包含所有 C(c/c++/obj-c 变体)的保留字。我想有些对所有编译器都有效,当然这些是针对 gcc 的。
至于找出要忽略的其他符号,在 OS X 上我会使用 nm 转储相关库的符号,并将所有标记为私有的符号(例如“s”而不是“S”)添加到我的符号列表中忽略。Linux 有类似的库转储工具吗?
希望这有用。