gpt4 book ai didi

c++ - 在源代码中查找引用的函数/变量定义

转载 作者:塔克拉玛干 更新时间:2023-11-03 06:45:00 25 4
gpt4 key购买 nike

我的项目包含很多文件。

有时我需要知道在源代码中某个特定函数的定义(实现)位置。我目前所做的是在源文件中文本搜索函数名称,这非常耗时。

我的问题是:有没有更好的方法(编译器/链接器标志)在源文件中找到该函数定义?....因为链接器已经解决了所有这些引用的所有问题。

我希望有比在调试器中进入函数调用更好的方法,因为一个函数可以隐藏在许多调用中。

最佳答案

尝试 cscope utility .

来自手册:

允许搜索代码:

  • 对符号的所有引用
  • 全局定义
  • 函数调用的函数
  • 函数调用函数
  • 文本字符串
  • 正则表达式模式
  • 一个文件
  • 文件包括一个文件

  • 基于 Curses(文本屏幕)

  • 生成一个信息数据库,以便更快地进行搜索和日后引用
  • 模糊解析器支持 C,但足够灵活,可用于 C++ 和 Java,并用作通用的“grep 数据库”(用它来浏览大型文本文档!)
  • 具有命令行模式以包含在脚本中或作为 GUI/前端的后端
  • 可在所有类型的 Unix 以及大多数垄断控制的操作系统上运行。

“截图”:

C symbol: atoi

File Function Line
0 stdlib.h <global> 86 extern int atoi (const char *nptr);
1 dir.c makefilelist 336 dispcomponents = atoi(s);
2 invlib.c invdump 793 j = atoi(term + 1);
3 invlib.c invdump 804 j = atoi(term + 1);
4 main.c main 287 dispcomponents = atoi(s);
5 main.c main 500 dispcomponents = atoi(s);
6 stdlib.h atoi 309 int atoi (const char *nptr) __THROW



Find this C symbol:
Find this global definition:
Find functions called by this function:
Find functions calling this function:
Find this text string:
Change this text string:
Find this egrep pattern:
Find this file:
Find files #including this file:

关于c++ - 在源代码中查找引用的函数/变量定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22971289/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com