使用ctags查找用c++中的构造函数声明的变量

Using ctags to find variables declared with a constructor in c++

本文关键字:构造函数 声明 变量 c++ ctags 查找 使用      更新时间:2023-10-16

使用此命令

ctags -R --c++-kinds=l -x test.cpp 

ctags只能找到变量c2而不能找到变量c3

代码片段:

int main()
{
  int c2 = 5;
  int c3(3);
  return 0;
}

通用ctags(https://ctags.io/)可以捕获c3。

[jet@localhost ctags]$ cat /tmp/foo.cpp
int main()
{
  int c2 = 5;
  int c3(3);
  return 0;
}
[jet@localhost ctags]$ ./ctags --kinds-C++=+l -o - /tmp/foo.cpp
c2  /tmp/foo.cpp    /^  int c2 = 5;$/;" l   function:main   typeref:typename:int    file:
c3  /tmp/foo.cpp    /^  int c3(3);$/;"  l   function:main   typeref:typename:int    file:
main    /tmp/foo.cpp    /^int main()$/;"    f   typeref:typename:int