Do you know the tree of building a tool for including files in a \ project file?

Let's say I would like to have a tool (or script?) Containing a project (or a .h file) and a constructed search tree that includes "included" (included in it and so on)). Is there something similar? Should I write it myself (of course, I :), but maybe someone already wrote or may have an idea of ​​how to get it?)

+4
source share
6 answers

Not quite sure if this is what you need, but you can easily get a list of inclusions by creating a post-CPP processed file from the base c file and grepping from file / line number comments, for example using gcc

gcc -E main.c {usual flags} | grep '#' | cut -d' ' -f3 | sort | uniq 

where main.c is your base c file.

+4
source

I know this is an old question, a slightly more useful conclusion than gcc / g ++ -E itself, also used the -H flag (instead or in addition):

g++ -H {my -I and other flags} -E -o /dev/null file.cpp

Here's an example of the conclusion, the tree structure helps to find out who included what, as a bonus, he also lists at the bottom which files can benefit from the included defender

 . generated/gen-cpp/File.h .. /usr/include/thrift/TProcessor.h ... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/string .... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/c++config.h ..... /usr/include/bits/wordsize.h ..... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/os_defines.h ...... /usr/include/features.h ....... /usr/include/sys/cdefs.h ........ /usr/include/bits/wordsize.h ....... /usr/include/gnu/stubs.h ........ /usr/include/bits/wordsize.h ........ /usr/include/gnu/stubs-64.h ..... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/x86_64-redhat-linux/bits/cpu_defines.h .... /usr/lib/gcc/x86_64-redhat-linux/4.4.6/../../../../include/c++/4.4.6/bits/stringfwd.h ... 
+3
source

If I remember correctly, doxygen can do this.

+1
source

Enable search is a pretty useful tool. It has some errors, and it has not been updated for some time, but the author provides a source, so you can change it to your liking.

enter image description here

+1
source

Eclipse CDT has Turn on browser in window → Show view → Other ... → C / C ++ → Turn on browser.

0
source

There is a tool called include gardener , which can be found here: https://github.com/feddischson/include_gardener. This gives you an inclusion tree in dot or graphml (xml) format. But it does not take into account other preprocessor statements, such as #if , #else , #endif .

0
source

All Articles