Generate CTAGS for libstdc ++ (from the current GCC)

I know LLVM -based YoucompleteMe , but I want to use OmniCppComplete . This works well if I use the modified headers for C ++. These modified headers are deprecated and do not contain anything from C ++ 11.

If you notice that I can modify my headers myself, for example:

$ find . -name '*.h' | xargs sed -i 's/__STL_BEGIN_NAMESPACE/namespace std {/'
$ find . -name '*.h' | xargs sed -i 's/__STL_END_NAMESPACE/}/'

Or use this parameter:

let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]

Both do not work, and of course most headers do not have any file extensions. I already tried to work around this using a list of files. How can I create working CTAGS based on my current GCC (e.g. / usr / include / C ++ / ...)? What is the general way?

thank

This is what I got if I try to do something from LIBSTD ++:

std::fs
Omni completion (^O^N^P) Back at original
Ctrl+x, Ctrl+o
Omni completion (^O^N^P) Pattern not found
+4
3

, LIBSTD++ (GCC). (!):

:
vim vim-omnicppcomplete ctags ( vim-omnicppcomplete).

:

$ cp -R /usr/include/c++/$GCC_VERSION ~/.vim/cpp_src
# it is not necessary to rename headers without an extension
# replace the "namespace std _GLIBCXX_VISIBILITY(default)" with "namespace std"
$ find . -type f | xargs sed -i 's/namespace std _GLIBCXX_VISIBILITY(default)/namespace std/'
$ ctags -f cpp_tags -R --c++-kinds=+p --fields=+iaS --extra=+q --language-force=C++ -I _GLIBCXX_NOEXCEPT cpp_src

~/.vimrc:

" configure tags - add additional tags here or comment out not-used ones
set tags+=~/.vim/cpp_tags
" build tags of your own project with Ctrl-F12
map <C-F12> :!ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q -I _GLIBCXX_NOEXCEPT .<CR>

" OmniCppComplete
let OmniCpp_NamespaceSearch = 1
let OmniCpp_GlobalScopeSearch = 1
let OmniCpp_ShowAccess = 1
let OmniCpp_ShowPrototypeInAbbr = 1 " show function parameters
let OmniCpp_MayCompleteDot = 1 " autocomplete after .
let OmniCpp_MayCompleteArrow = 1 " autocomplete after ->
let OmniCpp_MayCompleteScope = 1 " autocomplete after ::
" also necessary for fixing LIBSTDC++ releated stuff
let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD"]
" automatically open and close the popup menu / preview window
au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif
set completeopt=menuone,menu,longest,preview

LIBSTD++ vim!
Manuall Ctrl + x β†’ Ctrl + o.

, (. FAQ 7).

Bye

+4

OmniCppComplete ++ ( . , ++, boost, X11 ..). , Ubuntu 14.04:

ctags -f cpp_tags --c-kinds=cdefgmstuv --c++-kinds=cdefgmstuv --fields=+iaSmKz --extra=+q --langmap=c++:+.tcc. --languages=c,c++ -I "_GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_VISIBILITY+" -n $INC_DIR/* /usr/include/$CPP_TARGET/c++/$CPP_VERSION/bits/* /usr/include/$CPP_TARGET/c++/$CPP_VERSION/ext/* $INC_DIR/bits/* $INC_DIR/ext $SYSTEM/* $SYSTEM2/*

:

CPP_VERSION=4.8
INC_DIR=/usr/include/c++/$CPP_VERSION
CPP_TARGET=x86_64-linux-gnu
SYSTEM=/usr/lib/gcc/x86_64-linux-gnu/4.8/include
SYSTEM2=/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed

, - -I! . , /c-types/++ - .

:

tags+=cpp_tags

.vimrc , .

NO MODIFICATIONS . ++, , -I, ( ).

, , , , Vim Wiki.

let OmniCpp_DefaultNamespaces . let OmniCpp_DefaultNamespaces = ["std", "_GLIBCXX_STD", "_GLIBCXX_STD_A", "_GLIBCXX_STD_C"]. , .

, Vim CTRL-p std:: fs. ... !

+2

, , ++, ctags, , , . , ctags , .

-, , DONOT -I (. ), ctags. . , ctags , , C/++. , ctags . .

, ++, , /usr/include/c++/4.9.3 -I.

find/usr/include/++/-type f -exec grep '_GLIBCXX_' {} \; | grep -v -E '^ [# if | #end]' | sort -u > glibcxx.log

, ++ 4.9.3, , ctags.

++ :

ctags -R --languages ​​= ++ --langmap = ++:+. tcc. -C++ - = + + --fields = --extra = + QF -I "_GLIBCXX_NOEXCEPT _GLIBCXX_USE_NOEXCEPT _GLIBCXX_NOTHROW _GLIBCXX_USE_CONSTEXPR _GLIBCXX_BEGIN_NAMESPACE_CONTAINER _GLIBCXX_END_NAMESPACE_CONTAINER _GLIBCXX_CONSTEXPR _GLIBCXX_NAMESPACE_LDBL _GLIBCXX_BEGIN_NAMESPACE_VERSION _GLIBCXX_END_NAMESPACE_VERSION _GLIBCXX_VISIBILITY +" -f GCC-4.9.3.tags/USR//++/4.9.3/

Caveat

  • DONOT forget to write the .character of the next word tcc, this means matching these files without an explicit extension, for example vector,set
  • Donot forget to write the +sign of the next word VISIBILITY, it means matchingstd _GLIBCXX_VISIBILITY(**)
  • DONOT forget to write the character +followed by .tcc, this means adding the indicated extension to the current langugae map, otherwise replace the map
+1
source

Source: https://habr.com/ru/post/1546552/


All Articles