[英]How to find the file which declares a namespace variable?
I've got a program (LAMMPS, as it happens) spanning many .cpp/.h files, all of which share a namespace. 我有一个程序(LAMMPS,当它发生)跨越许多.cpp / .h文件,所有这些文件共享一个命名空间。 There are many variables referenced in source files, but which are initialised in some other file. 源文件中引用了许多变量,但在其他文件中初始化了这些变量。
Is there a way to find which file the variable is initialised in? 有没有办法找到变量初始化的文件?
Perhaps this is better placed in superuser, as I reckon some clever find/grep work could do this, but I'm not even sure what I'd be looking for (I don't know what type the variables are, for example). 也许这更适合超级用户,因为我认为一些聪明的find / grep工作可以做到这一点,但我甚至不确定我要找的是什么(例如,我不知道变量的类型) 。
Go with 'ctags'. 选择'ctags'。 It will create a cross reference listing of all the symbols in your code. 它将创建代码中所有符号的交叉引用列表。 Of course find & grep will work too :) 当然find&grep也会起作用:)
There are some good cross-referencing tools out there. 那里有一些很好的交叉引用工具。 Look for LXR, Cxref or OpenGrok. 寻找LXR,Cxref或OpenGrok。
This is one of my VIM favourites: 这是我最喜欢的VIM之一:
hit 击中
alternatively do the include search: 或者做包含搜索:
:isearch /regex/
Be sure to set path
to include your include paths: 请务必设置path
以包含您的包含路径:
:se path+=/usr/local/mylibrary/include
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.