【问题标题】:Why cscope don't search definitions in header files?为什么 cscope 不在头文件中搜索定义?
【发布时间】:2012-05-22 07:38:57
【问题描述】:

我使用以下命令来生成我的 cscope 数据库:

tmpfile=$(mktemp)
find dir1/ dir2/ dir3/ -type f -regex ".*\.\([chlysS]\(xx\|pp\)*\|cc\|hh\|inl\|inc\|ld\)$" -print > $tmpfile
cscope -q -b -U -i $tmpfile -f cscope.out

进入 vim,:cs f g myfunction 只引导我到 C 文件中的定义,而在头文件中。

【问题讨论】:

    标签: vim cscope


    【解决方案1】:

    确保您使用正确的术语。在 C 语言中,通常函数 definitions 放在 C 文件中,而 declarations 放在头文件中。

    cscope 命令 f g (find definition) 应该正确地将您带到函数 definition。如果您实际上在头文件中有定义(例如内联函数),则查找定义命令也会将您带到那里。如果不是这种情况,您应该向 cscope 团队提交错误报告。

    遗憾的是,Cscope 不提供仅显示声明的功能。您可以使用查找符号命令 (f s),但如果从代码中的许多位置调用该函数,这可能会显示很多结果。

    您可以使用 ctags,它通常允许您从声明或定义中进行选择。我通常在我的项目中混合使用 cscope 和 ctags,因为它们都没有提供我想要的所有功能。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多