如何快速搜索项目中所有包含的头文件中的特定符号? [英] How can I quickly search all included header files in a project for a specific symbol?

查看:106
本文介绍了如何快速搜索项目中所有包含的头文件中的特定符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我最近遇到的一个问题,就是这是这里其他人的共同痛苦.

Here's a problem I've had recently that just HAS to be a common pain to others here.

我正在使用其他人的遗留C代码,需要查找定义函数或宏的位置.除了特定项目中的代码外,代码#include还包含许多不同的标准系统库.

I'm working with someone else's legacy C code and need to find where a function or macro was defined. The code #includes a bunch of different standard system libraries in addition to those from the specific project.

是否有一种工具或技术可以快速找到定义特定功能,宏(或与此相关的其他全局变量)的位置?

Is there a tool or technique to quickly find where a specific function, macro, (or other global for that matter) was defined?

我尝试过:

grep -R 'function' /usr/lib

和其他类似的* nix/bash-fu,仅获得了有限的成功,并且有很多令人烦恼的谷壳被剔除.你们中的一位圣人编码人员必须对这种看似常见的情况有一个好的解决方案.

and other similar *nix/bash-fu with only limited success and lots of annoying chaff to cull. One of you sage coders out there must have a good solution to this seemingly common scenario.

我很惊讶地没有在这里或在搜索网络时找到关于这个特殊痛苦的另一个问题. (我敢肯定,如果我错过了一个... ;-),将会有愤怒的评论)

I was very surprised to not find another question on this particular pain here or in my searches of the interwebs. (I'm sure there will be angry comments if I missed one... ;-))

提前感谢您的提示!

推荐答案

使用旺盛的etags/ctags ctags项目,以及可以理解它们的编辑器(emacs,vim),或 GNU GLOBAL .

Use etags/ctags from the exuberant ctags project in conjunction with an editor (emacs, vim) that understands them, or GNU GLOBAL.

哦,如果碰巧使用automake,它会生成目标TAGS.因此,无需复杂的手动调用{c,e}tags.

Oh, and if you happen to use automake it generates a target TAGS. So no need for complicated manual calls to {c,e}tags.

这篇关于如何快速搜索项目中所有包含的头文件中的特定符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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