Listing C/C++ functions (Code analysis in Unix)(列出 C/C++ 函数(Unix 中的代码分析))
问题描述
无论我们是维护不熟悉的代码还是检查 Apache 模块的实现细节,如果我们能够快速遍历代码并构建我们正在查看的内容的概述,它都会有所帮助.Grep 满足了我大部分的日常需求,但在某些情况下它无法满足.
Whether we're maintaining unfamiliar code or checking out the implementation details of an Apache module it can help if we can quickly traverse the code and build up an overview of what we're looking at. Grep serves most of my daily needs but there are some cases where it just wont do.
以下是它如何提供帮助的一个常见示例.要找到我感兴趣的 PHP 函数的定义,我可以在命令行中输入:
Here's a common example of how it can help. To find the definition of a PHP function I'm interested in I can type this at the command line:
grep -r "function myfunc" .
如果我们知道返回类型,这可以很快适应 C 或 C++,但如果我想列出我的类提供的每个方法,事情就会变得更加复杂:
This could be adapted very quickly to C or C++ if we know the return type, but things become more complicated if, say, I want to list every method that my class provides:
grep "function " ./src/mine.class.php
由于在 C++ 中没有表示函数或方法的单个关键字,而且因为它通常是更复杂的语法,我想我需要某种静态代码分析工具、C 预处理器的巧妙使用或编码器遵循的盲目信仰严格的代码准则(空格数、卷曲位置等)以获得此类结果.
Since there's no single keyword that denotes a function or method in C++ and because it's generally more complex syntax, I think I'd need some kind of static code analysis tool, smart use of the C Preprocessor or blind faith the coder followed strict code guidelines (# of whitespace, position of curlies etc) to get these sorts of results.
你会推荐什么?
推荐答案
通过 doxygen 运行.它会抱怨没有注释,但它仍然会生成调用图并列出所有函数.以 HTML 格式显示,并带有用于跟踪代码路径的链接.
Run it through doxygen. It will complain about lack of commenting , but it will still produce call graphs and list all the functions. Presented in HTML with links to follow code paths.
doxygen
这篇关于列出 C/C++ 函数(Unix 中的代码分析)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:列出 C/C++ 函数(Unix 中的代码分析)


基础教程推荐
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01