4 ms·
In my project I was lucky to have started early on consistent naming conventions so that I could tell from names alone what headers were needed. Then my script
by makecheck 5y ago
In my project I was lucky to have started early on consistent naming conventions so that I could tell from names alone what headers were needed. Then my script to reduce unnecessary headers was primarily concerned with finding an #include without any other references to its name in the file.
Of course, that approach was only straightforward by imposing other constraints. It would not work for a random project.
One of the downsides of high language complexity is that “simple” concepts like this require a whole compiler to be able to handle every case.
Another downside of high language complexity is that we probably only care about unnecessary includes because there is such a cost to just referring to things. If module references were cheap, easy to cache, etc. then it wouldn’t matter if we have a few extra ones.