5

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. I configured and built global, et.al., only specifying --prefix. configure did find exhuberant and is using it. I've been trying global periodically over the years and it's always had this problem. Any ideas?

thanks, davep

4

2 回答 2

8

只需导出这个变量就可以了。从手册页gtags-

GTAGSFORCECPP If this variable is set, each file whose suffix is 'h' is treated as a C++ source file.

于 2014-11-04T00:16:04.177 回答
7

我发现我做错了什么。也许这会对某人有所帮助。

  1. 仅仅因为 configure 发现 exuberant ctags 并不意味着它使它成为默认解析器。我的前 ctags 不支持 --gtags,也许这就是原因。在我的例子中,默认的解析器是原生的/内置的。
  2. 本机解析器仅将 .h 视为 C 并且不查找 C++ 构造。奇怪的是,它也找不到结构。

我找到了 2 个修复:

1) 最好的,如果你有丰富的 ctags,将其设为默认值。丰富的默认配置可以正确处理 .h 文件。如果没有,请使用方法 2。在 .globalrc 中,更改

default:\   
  :tc=native:

to 

default:\   
  :tc=ctags:

2) 如果您没有丰富的 ctags,请编辑 .globalrc 并将内置解析器的 langmap 行从

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:

即删除.h 与C 的关联并将其与C++ 关联。这可能会导致 C .h 文件出现问题。如果是这样,您可能需要将所有C++ .h 文件重命名为 .hh、.hpp、.hxx 等,如 langmap 中给出的那样。

根据我使用 C++ 的经验,看起来大多数人仍然使用 .h 作为头文件。

于 2013-01-30T14:50:35.280 回答