GNU Global and GTAGS can't find class definitions

后端 未结 2 1073
野性不改
野性不改 2021-02-10 07:14

I\'m having trouble getting global to find class/struct definitions. I can find them with exuberant ctags and with cscope. All tag files are built from the same source file list

2条回答
  •  终归单人心
    2021-02-10 08:10

    I've found out what I did wrong. Maybe this will help someone.

    1. Just because configure finds exuberant ctags does not means that it makes it the default parser. My ex ctags doesn't support --gtags and maybe that's why. The default parser in my case was native/builtin.
    2. The native parser treats .h as C only and does not look for C++ constructs. Oddly, it also does not find structs.

    I found 2 fixes:

    1) The best, if you have exuberant ctags, is to make it the default. The exuberant default configuration processes .h files properly. If it does not, use method 2. In .globalrc, change

    default:\   
      :tc=native:
    
    to 
    
    default:\   
      :tc=ctags:
    

    2) If you do not have exuberant ctags, edit .globalrc and change the langmap line for the builtin-parser from

    builtin-parser:\
     :langmap=c\:.c.h,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.hh.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:
    
    to
    
    builtin-parser:\
     :langmap=c\:.c,yacc\:.y,asm\:.s.S,java\:.java,cpp\:.c++.cc.hh.h.cpp.cxx.hxx.hpp.C.H,php\:.php.php3.phtml:
    

    I.e. remove the association of .h with C and associate it with C++. This may cause problems with C .h files. If so, you may need rename ALL C++ .h files to .hh, .hpp, .hxx, etc, as given in the langmap.

    Based on my experience with C++, it looks like most people still use .h for their header files.

提交回复
热议问题