如何找到结构成员与cscope的使用而忽视局部变量? [英] How to find struct member uses with cscope and ignore local variables?

查看:327
本文介绍了如何找到结构成员与cscope的使用而忽视局部变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用cscope的与vim的一个大型项目,但没有vim的映射(他们愣了一些奇怪的原因,VIM)。我使用cscope的命令,从VIM内,我希望能够在整个code找到结构成员的用途。

I'm using cscope for a large project with vim, but without the vim mappings (they froze vim for some weird reason). I'm using cscope commands from within vim, and I want to be able to find uses of structure members throughout the code.

假设我有这样的事情:

  1 typedef struct _s{
  2     
  3     int x;
  4 } S;
  5  
  6 int main(){
  7
  8     int x = 1;
  9
 10     S my_s;
 11
 12     my_s.x = 5;
 13
 14     return my_s.x;
 15 }

如果我发出命令'CS五六X'将返回两者的s成员变量和局部主变。有没有办法我只能求S的成员变量的出现?

If I issue the command 'cs f s x' it will return both S's member variable and the local main variable. Is there a way I can only find the occurrences of S's member variable?

推荐答案

我不认为有什么办法让cscope的局部变量x和结构成员变量之间进行区分。

I don't think there is any way to get cscope to differentiate between the local variable x and the structure member variable.

我们解决在我的公司该问题的方法是使用一个独特的命名方案,成员变量,帮助区分他们:

The way we solve this problem at my company is to use a unique naming scheme for the member variables that helps differentiate them:

typedef struct _s{    
    int s_x;
} S;

这是起初有点尴尬,但一旦你习惯了它,但它更容易浏览code。通常情况下,唯一标志是只有几个字符有关的结构,它不添乱的东西也涨得厉害。

It's a little bit awkward at first, but once you get used to it, it does make it easier to navigate the code. Usually the uniquifier is only a few characters relevant to the structure, and it doesn't clutter things up too badly.

这篇关于如何找到结构成员与cscope的使用而忽视局部变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆