For all these reasons, I stopped after integrating support on macOS, not bothering to add support on Linux, and definitely not bothering to add it on

Don't Use include-what-you-use

submited by
Style Pass
2024-05-20 04:00:51

For all these reasons, I stopped after integrating support on macOS, not bothering to add support on Linux, and definitely not bothering to add it on Windows (which IWYU appears to have limited support for).

In conclusion, IWYU probably isn't worth your time, except maybe in extreme cases, e.g., if your codebase makes no use of forward declarations and you want to change that. Wait for modules to become mainstream instead.

In all but very simple projects, this would probably be better than just setting CMAKE_CXX_INCLUDE_WHAT_YOU_USE, which would analyze not just your own targets but also all 3rd-party dependencies.

The includes order would likely be incorrect, so run git-clang-format to amend. Take special care in files which have any preprocessor conditionals around includes: it's very likely IWYU would add missing includes not where you intend.

Repeat the last four steps until you get no warnings. As mentioned, sometimes new warnings can pop up after you handle all the ones in a previous batch.

Leave a Comment