如何才能轻松地看到C/ c++ #include图?

时间:2023-01-13 10:54:29

I'm looking for a tool (preferably, a Visual Studio plugin) that would display all files included by a given file and show all files included by those files and so on.

我正在寻找一个工具(最好是Visual Studio插件),它可以显示给定文件包含的所有文件,并显示这些文件包含的所有文件,等等。

7 个解决方案

#1


10  

Doxygen, with the aid of Graphviz, can do that. You first need to edit a configuration file. This won't be easy the first time you do it, but no much editing is needed afterwards.

在Graphviz的帮助下,Doxygen可以做到这一点。首先需要编辑配置文件。第一次这样做并不容易,但是之后不需要太多的编辑。

#2


16  

First, cinclude2dot.pl is a perl script which analyses C/C++ code and produces a #include dependency graph as a dot file for input into graphviz.

首先,cinclude2dot。pl是一个perl脚本,它分析C/ c++代码并生成一个#include依赖图作为输入到graphviz的点文件。

http://www.flourish.org/cinclude2dot/

http://www.flourish.org/cinclude2dot/

If you don't want to go the way of that sort of manual tool, then the hands-down by far winner is in my opinion a tool known as "IncludeManager" from ProFactor.

如果你不想走那种手工工具的路,那么在我看来,绝对的赢家就是ProFactor的“include demanager”。

http://www.profactor.co.uk/includemanager.php

http://www.profactor.co.uk/includemanager.php

There's a free trial, and it is awesome. It's a plug-in for Visual Studio that's totally integrated so double clicking on something over here takes you to the place where it is included over there.

有免费的试用,非常棒。它是Visual Studio的插件,完全集成在一起,双击这里的内容,你就会看到它所在的位置。

Tooltip mouseovers give you all the info you would want, and it lets you drill down / up, remove whole subtrees you don't care about, view representations other than graphs, cycle through a list of matches for this and that, it's wonderful.

工具提示鼠标悬停符提供了您想要的所有信息,它允许您向下/向上移动,删除您不关心的整个子树,查看除图形之外的表示,循环浏览匹配列表,这是非常棒的。

If you're quick about it, you can refactor the #include structure of a large projects before the trial runs out. Even so, it doesn't cost much, about $35 per license.

如果您能很快地做到这一点,您可以在试验结束之前重构大型项目的#include结构。即便如此,它也不会花很多钱,每个许可证大约35美元。

For what it does, it is just about perfect. Not only #include graphs but also cross project dependencies of shared files, impact on build times, detailed properties in grids, perfect.

对于它所做的一切,它几乎是完美的。不仅#包含图形,还包含共享文件的跨项目依赖,对构建时间的影响,网格中的详细属性,完美。

#3


9  

Not quite what you want perhaps, but the Visual Studio compiler (cl.exe) has an option /showIncludes which will show you a tree of the includes when you compile a file.

也许不是您想要的,但是Visual Studio编译器(cl.exe)有一个选项/ showinclude,它将在编译文件时显示包含的树。

If you want this information for a single file then you can right-click on the file in the Solution Explorer, select "Properties", and in the "Command Line" section just add /showIncludes to the "Additional Options". (Note I'm using VC++ 2005, so it may be different for newer versions).

如果您想要为单个文件获取这些信息,那么您可以右键单击解决方案资源管理器中的文件,选择“Properties”,在“命令行”部分,只需向“附加选项”添加/ showinclude。(注意,我使用的是vc++ 2005,所以新版本可能会有所不同)。

The output that you get is a little... convoluted, but it shows you what gets included and in what order.

你得到的输出有点。令人费解,但它向您展示了包含的内容和顺序。

Incidentally, the same feature in GCC and the Intel C++ compiler (my versions at least) is -H.

顺便说一句,GCC和Intel c++编译器(至少是我的版本)中的相同特性是-H。

#4


4  

If you are using Visual Studio 2010 you can use the new Visualization and Modelling Feature Pack from Microsoft, which has a feature to generate an include graph. This is only available through an MSDN subscript though.

如果您正在使用Visual Studio 2010,您可以使用来自Microsoft的新的可视化和建模功能包,它具有生成包含图的功能。不过,这只能通过MSDN下标获得。

#5


4  

You can try the method suggested by this Stack Overflow answer:

您可以尝试这个堆栈溢出答案建议的方法:

There is a C/C++ -> Advanced project setting "show Includes". That will generate the tree. It maps to the compiler switch /showIncludes

有一个C/ c++ ->高级项目设置“show include”。它会生成树。它映射到编译器开关/ showinclude

#6


2  

Not in your preferences, but doxygen does that quite well.

不是你的偏好,但doxygen做得很好。

#7


0  

http://www.codeproject.com/KB/applications/includefinder.aspx

http://www.codeproject.com/KB/applications/includefinder.aspx

This is not a VS plug-in but can be a starter for your own tool. As far as I could see it reads VC6 projects only, the newer VS have an XML format easy to parse. What you need out of it are the default include paths so the tool can find the included files. Alternatively you could provide a settings box for it in the GUI as user input.

这不是一个VS插件,但可以作为您自己的工具的启动器。就我所见,它只读取VC6项目,新的VS具有易于解析的XML格式。您需要的是默认的包含路径,这样工具就可以找到包含的文件。您也可以在GUI中为它提供一个设置框作为用户输入。

#1


10  

Doxygen, with the aid of Graphviz, can do that. You first need to edit a configuration file. This won't be easy the first time you do it, but no much editing is needed afterwards.

在Graphviz的帮助下,Doxygen可以做到这一点。首先需要编辑配置文件。第一次这样做并不容易,但是之后不需要太多的编辑。

#2


16  

First, cinclude2dot.pl is a perl script which analyses C/C++ code and produces a #include dependency graph as a dot file for input into graphviz.

首先,cinclude2dot。pl是一个perl脚本,它分析C/ c++代码并生成一个#include依赖图作为输入到graphviz的点文件。

http://www.flourish.org/cinclude2dot/

http://www.flourish.org/cinclude2dot/

If you don't want to go the way of that sort of manual tool, then the hands-down by far winner is in my opinion a tool known as "IncludeManager" from ProFactor.

如果你不想走那种手工工具的路,那么在我看来,绝对的赢家就是ProFactor的“include demanager”。

http://www.profactor.co.uk/includemanager.php

http://www.profactor.co.uk/includemanager.php

There's a free trial, and it is awesome. It's a plug-in for Visual Studio that's totally integrated so double clicking on something over here takes you to the place where it is included over there.

有免费的试用,非常棒。它是Visual Studio的插件,完全集成在一起,双击这里的内容,你就会看到它所在的位置。

Tooltip mouseovers give you all the info you would want, and it lets you drill down / up, remove whole subtrees you don't care about, view representations other than graphs, cycle through a list of matches for this and that, it's wonderful.

工具提示鼠标悬停符提供了您想要的所有信息,它允许您向下/向上移动,删除您不关心的整个子树,查看除图形之外的表示,循环浏览匹配列表,这是非常棒的。

If you're quick about it, you can refactor the #include structure of a large projects before the trial runs out. Even so, it doesn't cost much, about $35 per license.

如果您能很快地做到这一点,您可以在试验结束之前重构大型项目的#include结构。即便如此,它也不会花很多钱,每个许可证大约35美元。

For what it does, it is just about perfect. Not only #include graphs but also cross project dependencies of shared files, impact on build times, detailed properties in grids, perfect.

对于它所做的一切,它几乎是完美的。不仅#包含图形,还包含共享文件的跨项目依赖,对构建时间的影响,网格中的详细属性,完美。

#3


9  

Not quite what you want perhaps, but the Visual Studio compiler (cl.exe) has an option /showIncludes which will show you a tree of the includes when you compile a file.

也许不是您想要的,但是Visual Studio编译器(cl.exe)有一个选项/ showinclude,它将在编译文件时显示包含的树。

If you want this information for a single file then you can right-click on the file in the Solution Explorer, select "Properties", and in the "Command Line" section just add /showIncludes to the "Additional Options". (Note I'm using VC++ 2005, so it may be different for newer versions).

如果您想要为单个文件获取这些信息,那么您可以右键单击解决方案资源管理器中的文件,选择“Properties”,在“命令行”部分,只需向“附加选项”添加/ showinclude。(注意,我使用的是vc++ 2005,所以新版本可能会有所不同)。

The output that you get is a little... convoluted, but it shows you what gets included and in what order.

你得到的输出有点。令人费解,但它向您展示了包含的内容和顺序。

Incidentally, the same feature in GCC and the Intel C++ compiler (my versions at least) is -H.

顺便说一句,GCC和Intel c++编译器(至少是我的版本)中的相同特性是-H。

#4


4  

If you are using Visual Studio 2010 you can use the new Visualization and Modelling Feature Pack from Microsoft, which has a feature to generate an include graph. This is only available through an MSDN subscript though.

如果您正在使用Visual Studio 2010,您可以使用来自Microsoft的新的可视化和建模功能包,它具有生成包含图的功能。不过,这只能通过MSDN下标获得。

#5


4  

You can try the method suggested by this Stack Overflow answer:

您可以尝试这个堆栈溢出答案建议的方法:

There is a C/C++ -> Advanced project setting "show Includes". That will generate the tree. It maps to the compiler switch /showIncludes

有一个C/ c++ ->高级项目设置“show include”。它会生成树。它映射到编译器开关/ showinclude

#6


2  

Not in your preferences, but doxygen does that quite well.

不是你的偏好,但doxygen做得很好。

#7


0  

http://www.codeproject.com/KB/applications/includefinder.aspx

http://www.codeproject.com/KB/applications/includefinder.aspx

This is not a VS plug-in but can be a starter for your own tool. As far as I could see it reads VC6 projects only, the newer VS have an XML format easy to parse. What you need out of it are the default include paths so the tool can find the included files. Alternatively you could provide a settings box for it in the GUI as user input.

这不是一个VS插件,但可以作为您自己的工具的启动器。就我所见,它只读取VC6项目,新的VS具有易于解析的XML格式。您需要的是默认的包含路径,这样工具就可以找到包含的文件。您也可以在GUI中为它提供一个设置框作为用户输入。