Tool to track #include dependencies [closed]

2019-01-01 14:00发布

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.

标签: c++ c header
11条回答
旧人旧事旧时光
2楼-- · 2019-01-01 14:56

Good news: redhat Source-Navigator (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.

redhat Source-Navigator

查看更多
只若初见
3楼-- · 2019-01-01 14:56

Understand for C++ should be able to help you: it builds a database that you can access from Perl.

查看更多
素衣白纱
4楼-- · 2019-01-01 14:57

If you have access to GCC/G++, then the -M option 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.

查看更多
弹指情弦暗扣
5楼-- · 2019-01-01 14:59

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.

Screen shot

查看更多
浮光初槿花落
6楼-- · 2019-01-01 15:05

cscope (http://cscope.sourceforge.net/) does this in a standalone xterm, and also can be used inside your favorite editor - it has great emacs and vi/vim support.

查看更多
登录 后发表回答