<p>Any good suggestions? Input will be the name of a header file and output should be a list (preferably a tree) of all files including it directly or indirectly.</p>

[{'answer_id': 42316, 'author': 'Matt Dillard', 'author_id': 863, 'author_profile': 'https://Stackoverflow.com/users/863', 'pm_score': 5, 'selected': False, 'text': '<p>For a heavy weight solution, you should check out <a href="http://www.doxygen.nl/" rel="nofollow noreferrer">doxygen</a>.  It scans through your code base and comes up with a website, effectively, that documents your code.  One of the many things it shows is include trees.</p>\n\n<p>If you were looking to be able to plug the output of this tool into some other process, then this may not work for you (although doxygen does output to other formats, I\'m not real familiar with that feature).  If you simply want to eyeball the dependencies, though, it should work great.</p>\n'}, {'answer_id': 42324, 'author': 'Brian Stewart', 'author_id': 3114, 'author_profile': 'https://Stackoverflow.com/users/3114', 'pm_score': 4, 'selected': False, 'text': '<p>I\'ve played around with a tool called <a href="http://flourish.org/cinclude2dot/" rel="noreferrer">cinclude2dot</a>. It was pretty useful in getting a handle on a rather large codebase when I came to work here. I\'ve actually thought about integrating it into our daily build eventually.</p>\n'}, {'answer_id': 42405, 'author': 'Xavier Nodet', 'author_id': 4177, 'author_profile': 'https://Stackoverflow.com/users/4177', 'pm_score': 2, 'selected': False, 'text': '<p><a href="http://www.scitools.com/products/understand/" rel="nofollow noreferrer">Understand for C++</a> should be able to help you: it builds a database that you can access from Perl.</p>\n'}, {'answer_id': 42513, 'author': 'KeithB', 'author_id': 2298, 'author_profile': 'https://Stackoverflow.com/users/2298', 'pm_score': 8, 'selected': True, 'text': '<p>If you have access to GCC/G++, then the <a href="http://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html#Preprocessor-Options" rel="noreferrer"><code>-M</code> option</a> will output the dependency list.  It doesn\'t do any of the extra stuff that the other tools do, but since it is coming from the compiler, there is no chance that it will pick up files from the "wrong" place.</p>\n'}, {'answer_id': 42673, 'author': 'dwj', 'author_id': 346, 'author_profile': 'https://Stackoverflow.com/users/346', 'pm_score': 3, 'selected': False, 'text': '<p>You can also check out <em>makedepend</em>:</p>\n\n<p><a href="http://en.wikipedia.org/wiki/Makedepend" rel="noreferrer">http://en.wikipedia.org/wiki/Makedepend</a></p>\n\n<p><a href="http://www.xfree86.org/current/makedepend.1.html" rel="noreferrer">http://www.xfree86.org/current/makedepend.1.html</a></p>\n'}, {'answer_id': 42998, 'author': 'Agnel Kurian', 'author_id': 45603, 'author_profile': 'https://Stackoverflow.com/users/45603', 'pm_score': 7, 'selected': False, 'text': '<p>Thanks to KeithB. I looked up the docs for cl.exe (VS2008) and found the /showIncludes flag. From the IDE, this can be set from the property page of any CPP file.</p>\n\n<p><img src="https://i.stack.imgur.com/3XkHJ.png" alt="Screen shot"></p>\n'}, {'answer_id': 43382, 'author': 'Agnel Kurian', 'author_id': 45603, 'author_profile': 'https://Stackoverflow.com/users/45603', 'pm_score': 4, 'selected': False, 'text': '<p>Good news: <a href="http://sourcenav.sourceforge.net/" rel="noreferrer">redhat Source-Navigator</a> (runs on Windows too). Of course, compiler switches (mentioned earlier) have superior parsing and I\'m not sure how this will handle MFC, Qt and their magic keywords.</p>\n\n<p><img src="https://i.stack.imgur.com/84sxR.png" alt="redhat Source-Navigator"></p>\n'}, {'answer_id': 47236, 'author': 'svec', 'author_id': 103, 'author_profile': 'https://Stackoverflow.com/users/103', 'pm_score': 2, 'selected': False, 'text': '<p>cscope (<a href="http://cscope.sourceforge.net/" rel="nofollow noreferrer">http://cscope.sourceforge.net/</a>) does this in a standalone xterm, and also can be used inside your favorite editor - it has great emacs and vi/vim support.</p>\n'}, {'answer_id': 1763463, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': '<p>Building on <a href="https://stackoverflow.com/a/42513/2877364">KeithB\'s answer</a>, here is GNUmake syntax to automatically 1) generate the dependency files, 2) keep them up to date, and 3) use them in your makefile:</p>\n\n<pre><code>.dep:\n    mkdir $@\n.dep/%.dep: %.c .dep\n    (echo $@ \\\\; $(CC) $(IFLAGS) -MM $&lt;) &gt; $@ || (rm $@; false)\n.dep/%.dep: %.cpp .dep\n    (echo $@ \\\\; $(CXX) $(IFLAGS) -MM $&lt;) &gt; $@ || (rm $@; false)\nDEPEND := $(patsubst %.dep,.dep/%.dep,$(OBJ:.o=.dep))\n-include $(DEPEND)\n</code></pre>\n\n<p>(Make sure to change those indents to hardtabs.)</p>\n'}, {'answer_id': 3074336, 'author': 'Allbite', 'author_id': 290091, 'author_profile': 'https://Stackoverflow.com/users/290091', 'pm_score': 4, 'selected': False, 'text': '<p>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. </p>\n\n<p><a href="http://www.flourish.org/cinclude2dot/" rel="noreferrer">http://www.flourish.org/cinclude2dot/</a> </p>\n\n<p>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.</p>\n\n<p><a href="http://www.profactor.co.uk/includemanager.php" rel="noreferrer">http://www.profactor.co.uk/includemanager.php</a></p>\n\n<p>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. </p>\n\n<p>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.</p>\n\n<p>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. </p>\n\n<p>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.</p>\n'}]
['https://Stackoverflow.com/questions/42308', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/45603/']