|
Boost Users : |
From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2004-07-05 10:57:55
Adrian Stoica <adrian_stoica_at_[hidden]> wrote:
> I'm not aware of any such tools, but it could be done with a Perl
> script that removes the includes one at a time, and then invokes the
> compiler. If the file compiles ok, it's probably safe to remove that
> include.
No, unfortunately not. A header might appear to be redundant because
it is included by another, yet this may be a mere implementation detail
which is subject to change and should not be relied upon. In the
absence of a true module system this is impossible to determine. Also
it could be that the header defines template specialisations, or macros
with the same names as functions/objects. Removing such a header might
not make the program ill-formed but could still break it subtly.
Instantiating a template in one translation unit for the same template
arguments for which there is an explicit specialisation in another
translation unit results in undefined behaviour. With sufficient
testing you can *probably* avoid such mishaps but I would be very wary
of trying to automate this.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net