Say, I'd like to have a tool (or script?) taking project (or .h file) and building searchable tree of "includes" included into it (of included into of included into and so so on). Is there exist something like this? Should I write this by myself [of course I am :), but may be somebody had it already written or may be has an idea how to get it]?
+2
A:
Not entirely sure this is what you're after, but you can easily get a list of includes by generating the post-CPP-processed file from the base c file, and grepping out the file/line number comments, e.g., using gcc
gcc -E main.c {usual flags} | grep '#' | cut -d' ' -f3 | sort | uniq
where main.c is your base c file.
jon hanson
2009-08-04 09:58:56
This is how I have done it in the past (except with MSVC). The hard part of automating is getting the correct compile flags, from either projects or makefiles) as these can effect what files are included when.
iain
2009-08-04 11:15:11
Thanks. In common, "I'm after" .h file (consequence of includes) in big and old project causing failures. I am interested in MSVC, but if I not receive better answer - this will do.
bgee
2009-08-05 14:34:44
jon hanson
2009-08-05 14:56:36