https://stackoverflow.com/a/26725652/257924指定了一个有用的环境变量,调用该变量GTAGSFORCECPP
以强制.h
将文件视为 C++(否则,C++ 类定义不会作为符号添加到标签数据库中)。理想情况下,我不必在我的启动脚本中设置那个 env var,而是让它以某种方式表达到一个位于中心的 gtags.conf 中,可以与网络中的其他开发人员共享。gtags 手册(特别是本节)的措辞使我相信这是可能的:
You can use the following environment variables as a string
variable. If these variables are set then environment variables of
the same name are set before command execution.
GREP_COLOR
GREP_COLORS
GTAGSBLANKENCODE
GTAGSCACHE
GTAGSFORCECPP
GTAGSGLOBAL
GTAGSGTAGS
GTAGSLIBPATH
GTAGSLOGGING
GTAGSTHROUGH
GTAGS_OPTIONS
HTAGS_OPTIONS
MAKEOBJDIR
MAKEOBJDIRPREFIX
TMPDIR
The following variables are also available as a string
variable. By default, each of them has a directory path given by
the configure script.
bindir
datadir
libdir
localstatedir
sysconfdir
但是,我不确定在哪里表达它。例如,像这样添加它会导致解析错误,所以这是不正确的:
#
# Built-in parsers.
#
gtags:\
:tc=common:\
:tc=builtin-parser:\
:GTAGSFORCECPP=1:
我真正想要的是强制所有.h
文件都被视为 C++,所以可能有更好的方法来解决它。