sön 2010-12-05 klockan 15:28 +0100 skrev Kinkie: > Hi all, > Eric Raymond recently released a tool named deheader > (http://www.catb.org/esr/deheader/) which goes through c/c++ project > looking for unneeded includes. > It does so by trying to compile each source file after removing one > #include statement at a time, and seeing if it builds.
Which is interesting, but a lot of filtering is needed to make use of the results. Many times OS headers is quite forgiving, allowing you to skip many includes which is documented as required for a certain function. For example socket(2) officially requires sys/types.h and sys/socket.h, but many OS:es accept if you just include sys/socket.h. And we do have some magics in our own sources where stripping an Squid include would make that file still compile but result in missing functionality. Most times this will result in link failure however as long as config.h is always included one way or another. I would use the tool very cautious. It's interesting, but the results can not automatically be taken as a truth, only a hint. Personally I don't have a big problem with a bit too many includes. Regards Henrik