c++ - 查看包含依赖项

标签 c++ code-analysis analysis

有谁知道可以分析 C++ 代码库并显示哪些文件包含哪些头文件并突出显示冗余包含的图形表示的工具?我使用过 Understand C++,但它很昂贵,而且在大型(且封装不佳的)代码库上很快变得非常笨重。

最佳答案

gcc/g++ 总是有"-H" 选项...

例如:% g++ -H foo.C

'-H'
     Print the name of each header file used, in addition to other
     normal activities.  Each name is indented to show how deep in the
     '#include' stack it is.  Precompiled header files are also
     printed, even if they are found to be invalid; an invalid
     precompiled header file is printed with '...x' and a valid one
     with '...!' .

然后:

  • 'sed' 或 'awk' 删除前导 '...'。
  • '排序使相同的名字相邻。
  • 'uniq -c' 来计算名字。
  • 'grep -v' 删除单例。

如:

%  g++ -H  foo.C |& awk '{print $2}' | sort | uniq -c | grep -v '      1 '

或者这对你来说太 linux'y/unix'y 了吗?

(windows下,总有cygwin。)

关于c++ - 查看包含依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/426860/

相关文章:

c++ - 我需要一个库来加载图像

c++ - 如何嵌入 Webkit/Gecko 布局引擎并开始将其用于 UI?

c++ - 在实例化派生类时指定基类模板参数?

c# - 通用纯文本 linting 工具

c# - 以编程方式检查 .NET 代码

algorithm - 嵌套for循环的运行时间

algorithm - 大哦符号

c++ - 如何避免相似模板中的代码重复

c# - 检查c#方法的速度和内存大小

search - Elasticsearch:如何获取字符串字段的长度(分析前)?