From: Vladimir Prus (ghost_at_[hidden])
Date: 2003-10-17 08:26:47
Jonathan de Halleux wrote:
> Yes of course,
> Here's another idea on the subject:
> Suppose you have a C++ parser on hand (using Spirit for instance) so you
> could parse the files and create a dependency (directed) graph using the
> BGL. In this graph, the files are the nodes and the edges are the
> #include. (this problem is so important that it is one of the BGL
> examples). (Doxygen already does that)
Boost.Build can output the dependency graph already. You should parse that
graph, but it's somewhat simpler than parsing C++.
> From there, a lot could be done using graph theory. For instance:
> - by sorting the nodes by edges number, you can detect which files are
> the most often included. In boost, I suppose it would be
> - since making forward declaration enables to break some edges, could
> this algorithm be used to find which dependency could be replaced by a
> forward declaration ?
How? You can use forward declaration only if header in question does not
declare instances of the class, but only pointers, or, say, vectors. To
find if this is the case, you'd need real C++ parser.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk