开发者

How can I see the C/C++ #include graph easily? [closed]

开发者 https://www.devze.com 2023-01-03 18:17 出处:网络
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
开发者_高级运维

We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.

Closed 7 years ago.

Improve this question

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.


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.

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.

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.

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.

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.


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.


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.

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

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.


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


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.


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


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消