Header dependencies

E

eric

Any C/C++ tools out there that can generate/display header
dependencies (i.e. order of inclusion), possibly in visual format
(e.g. graphs)?

The dependencies generated by most compilers only show all header
dependencies of a source file. That is, if you have one source file
that includes many header files, a typical compiler will only generate
a single Makefile dependency rather than individual dependencies. For
example:

[user@host dependencies]$ ls
test01.h test02.h test03.h test04.cpp test04.h
[user@host dependencies]$ more test*
::::::::::::::
test01.h
::::::::::::::

#define FOO foo

::::::::::::::
test02.h
::::::::::::::

#include "test03.h"

::::::::::::::
test03.h
::::::::::::::

#define BAR bar

::::::::::::::
test04.cpp
::::::::::::::

#include "test04.h"

int main () {
return 0;
}

::::::::::::::
test04.h
::::::::::::::

#include "test01.h"
#include "test02.h"

[user@host dependencies]$ g++ -MM test04.cpp
test04.o: test04.cpp test04.h test01.h test02.h test03.h

What I would like to see is something like this:

test04.o: test04.cpp test04.h
test04.h: test01.h test02.h
test02.h: test03.h

Would greatly appreciate any tips, pointers, links, etc.

Eric.
 
C

Craig Scott

Any C/C++ tools out there that can generate/display header
dependencies (i.e. order of inclusion), possibly in visual format
(e.g. graphs)?

Doxygen does a good job of this. It can create HTML pages with
clickable graphs generated using dot. Also, if you haven't already,
take a browse through the C++ FAQ for more great info:

http://www.parashift.com/c++-faq-lite/

Anyone feel like adding something about header file inclusion graphs
using doxygen to the C++ FAQ? It has come up a few times lately.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,128
Latest member
ElwoodPhil
Top