查看包含依赖项

发布于 2024-07-11 02:10:04 字数 113 浏览 12 评论 0原文

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

Does anyone know of a tool that will analyse a C++ codebase and display a graphical representation of which files include which header files and highlight redundant includes? I've used Understand C++ but it's expensive and became very unwieldy very quickly on a large (and poorly encapsulated) codebase.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我三岁 2024-07-18 02:10:04

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。)

There's always the "-H" option to gcc/g++...

Eg.: % 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 '...!' .

Then:

  • 'sed' or 'awk' to remove the leading '...'.
  • 'sort to make same names adjacent.
  • 'uniq -c' to count names.
  • 'grep -v' to remove singletons.

As in:

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

Or is that too linux'y / unix'y for you?

(Under windows, there's always cygwin.)

还在原地等你 2024-07-18 02:10:04

试试这个

跟踪 #include 依赖项的工具

这听起来像是一个非常简单的练习你自己的一个。 添加“冗余”包括确定,但可能更具挑战性。 人们必须解析并遵循 ifdef 等。 但对于仅仅制作依赖树来说,这是非常简单的。

try this

Tool to track #include dependencies

It also sounds like a very simple exercise to write one of your own. Adding "redundant" include determination though might be more challenging. One would have to parse and follow ifdefs and the like. But for just making a tree of dependencies it is pretty straightforward.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文