我正在阅读xl2tpd
的源代码,在阅读这段代码时遇到很多问题。例如,我找不到结构 lac
的定义位置。我如何找到这个结构的定义?
我使用ctags和vim阅读了这段代码,但未能找到结构。我用谷歌搜索并找不到结构。有没有什么方法可以让代码阅读过程变得更舒服呢?也就是说,我可以跳转到大多数变量、函数和结构的定义?
I am reading source code of xl2tpd
, and face lots of problems when reading this code. For example I cannot find where the structure lac
is defined. How do I find the definition of this structure?
I have used ctags and vim to read this code, but failed to find the structure. I googled and could not find the structure. Is there any method that can make the code reading process more comfortable? That is, I can jump to definition of most variables, functions and structures?
发布评论
评论(4)
尝试使用 vim 来使用 cscope。请按照以下步骤操作 -
1)在xl2tpd目录中运行
cscope -R
。它将创建文件 cscope.out2)用vim打开文件,其中使用结构
lac
3) 使用
:cs fg
。现在它将显示定义lac
的文件。4) 选择
file.h
。它包含定义。如果您对 struct lac 的定义特别感兴趣,它如下 -
try cscope with vim. follow steps below -
1) run
cscope -R
in xl2tpd directory . it will create file cscope.out2) open file with vim where structure
lac
is used3) use
:cs f g <lac>
. now it will show the files wherelac
is defined .4) choose
file.h
. it contain the definition .if you are perticulerly interested in definition of struct
lac
it is below -在浏览第三方代码时,我发现有一些非常有价值的工具:
Source Navigator
lxr
ctags
当然,还有最古老和最伟大的:grep
我相信 Eclipse CDT 也可以让你快速找到您正在查找的任何变量的定义at,但我还没有实际使用它 - 我更喜欢使用控制台程序来进行实际的 C 编码。
尽管至少可以通过
vim
或emacs
使用ctags
,但这些都不是基于vim
的。尽管如此,当探索您一无所知的新代码库时,它们可能非常有用......When going through third-party code, there are a few tools that I have found invaluable:
Source Navigator
lxr
ctags
and, of course, the oldest and greatest of all: grep
I believe that the Eclipse CDT also allows you to quickly find the definition of any variable you are looking at, but I have not actually used it - I prefer using console programs for my actual C coding.
None of those are
vim
-based, although at leastctags
can be used viavim
oremacs
. Nevertheless, they can be very useful when exploring a new codebase that you know nothing about...您在谈论这个吗?
源代码已附带一个
tags
文件。在 Vim 中加载任何文件(在我的例子中为
common.h
),您可以使用:tag lac
跳转到lac
或 < code>:tselect lac 在此项目中的 3 个匹配项之间进行选择,:tag gconfig
跳转到gconfig
的唯一定义。请参阅
:帮助标签
。Are you talking about this?
The source code already comes with a
tags
file.Loading any file (
common.h
in my case) in Vim you can use:tag lac
to jump to the first definition oflac
or:tselect lac
to choose between the 3 occurrences in this project and:tag gconfig
to jump to the unique definition ofgconfig
.See
:help tags
.我正在使用 vim + cscope 并与你有同样的问题。我找到了解决这个问题的方法。
在 vim 中,搜索文本而不是定义。例如,在linux内核源代码中,如果你试图找到“struct file”,
命令如下:
cs find t struct file {
在大多数情况下,您将及时得到准确的定义,请注意,文本“struct file {”没有引号。
希望它能帮助你。
I'm using vim + cscope and have the same issue with you. I find a way to workaround this issue.
in vim, search the text instead of the definition. for example, in the linux kernel source code, if you're trying to find "struct file",
commands this:
cs find t struct file {
you will have a accurate definition timely in most cases, take care, no quotation mark for the text "struct file {".
hope it will help you.