ctags ignore lists for libc6, libstdc++ and boost

后端 未结 4 663
独厮守ぢ
独厮守ぢ 2020-12-29 22:05

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

相关标签:
4条回答
  • 2020-12-29 22:34

    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:

    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()
    
    0 讨论(0)
  • 2020-12-29 22:38

    I have followed those instructions and I am able to get all boost boost references working i.e.

    #include <iostream>
    

    I can jump directly to iostream

    However what I am still missing is to go to for example

    #include <stdio.h>
    

    Although in my generate script I have included as you mentioned i.e.

    $ 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 
    

    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.

    set tags+=~/.vim/tags/boost
    set tags+=~/.vim/tags/libc6
    set tags+=~/.vim/tags/stdlibcpp
    

    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

    # 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
    
    apt-file list libstdc++6-4.6-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
    
    0 讨论(0)
  • 2020-12-29 22:50

    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:

    __attribute__
    __attribute_deprecated__
    __attribute_format_arg__+
    __attribute_format_strfmon__+
    __attribute_malloc__
    __attribute_noinline__
    __attribute_pure__
    __attribute_used__
    __attribute_warn_unused_result__
    __attribute_alloc_size__+
    __attribute_const__
    __attribute_artificial__
    __wur
    __THROW
    __THROWNL
    __BEGIN_DECLS
    __END_DECLS
    __BEGIN_NAMESPACE_STD
    __END_NAMESPACE_STD
    __USING_NAMESPACE_STD+
    __BEGIN_NAMESPACE_C99
    __END_NAMESPACE_C99
    __USING_NAMESPACE_C99+
    __warndecl+
    __warnattr+
    __errordecl+
    __flexarr=[]
    __fortify_function
    __REDICRECT+
    __REDIRECT_NTH+
    __REDIRECT_NTHNL+
    __ASMNAME+
    __ASMNAME2+
    __nonnull+
    __always_inline
    __extern_inline=extern
    __extern_always_inline=extern
    __extension__
    __restrict
    __restrict_arr
    

    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):

    _GLIBCXX_BEGIN_NAMESPACE_VERSION
    _GLIBCXX_END_NAMESPACE_VERSION
    _GLIBCXX_BEGIN_NAMESPACE_ALGO
    _GLIBCXX_END_NAMESPACE_ALGO
    _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
    _GLIBCXX_END_NAMESPACE_CONTAINER
    _GLIBCXX_BEGIN_EXTERN_C
    _GLIBCXX_END_EXTERN_C
    _GLIBCXX_VISIBILITY+
    _GLIBCXX_PURE
    _GLIBCXX_CONST
    _GLIBCXX_NORETURN
    _GLIBCXX_CONSTEXPR=constexpr
    _GLIBCXX_USE_CONSTEXPR=constexpr
    _GLIBCXX_THROW_OR_ABORT+
    _GLIBCXX_NOEXCEPT
    _GLIBCXX_USE_NOEXCEPT
    _GLIBCXX_THROW+
    _GLIBCXX_NOTHROW
    

    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.

    0 讨论(0)
  • 2020-12-29 22:57

    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.

    0 讨论(0)
提交回复
热议问题