Alex Rivera | Logout

Are there tools that help organizing #includes?

Asked 2010-09-04T22:56:35.043
25

Are there any tools that help organizing the #includes that belong at the top of a .c or .h file?

I was just wondering because I am reorganizing my code, moving various small function definitions/declarations from one long file into different smaller files. Now each of the smaller files needs a subset of the #includes that were at the top of the long file.

It's just annoying and error-prone to figure out all #includes by hand. Often the code compiles even though not all #includes are there. Example: File A uses std::vector extensively but doesn't include vector; but it currently includes some obscure other header which happens to include vector (maybe through some recursive includes).

Edit
Report

2 Answers

1
answered 2010-09-04T23:27:23.677
0

I use the doxygen/dot-graphviz generated graphs to see how files are linked. Very handy, but not automatic, you have to visually check the graphs, then edit you code to remove unnecessary "#include" lines. Of course, not really suited for very-large projects (say > 100 files), where the graphs become unusable.

answered 2010-11-09T11:20:18.193

Your Answer