3 ms·
Include-what-you-use won't make your stuff build faster, unless you end up removing lots of headers. What it will do is make your codebase more stable by forcin
by wakawaka28 2y ago
Include-what-you-use won't make your stuff build faster, unless you end up removing lots of headers. What it will do is make your codebase more stable by forcing people to include stuff that is referenced in the current file. Some people find it annoying when their indirectly included header changes or disappears and that breaks the build. I believe there is also the expectation that you will forward declare tons of stuff. That will speed up your build, but it's a lot of work. I wouldn't do it unless I had serious problems with build times that couldn't be solved otherwise.
I haven't used IWYU in years. It's an ok idea but I have bigger fish to fry, and including everything you reference is kinda verbose. What I do is I include anything particular to the current cpp file, and let everything else be indirect. If it someday breaks the build when I change includes upstream, I'll fix it. That takes less time than maintaining IWYU stuff IMO.
Of course if you are writing headers, you really ought to be more careful and include more stuff, if it's fast enough at compile time. It's stupid to have to include a header and then have to include a separate header with primitive types or something before you can do anything.