INCLUDE-WHAT-YOU-USE(1)

πŸ’– INCLUDE-WHAT-YOU-USE(1) πŸ’–

okay bestie, gather round, because this is the manual page for include-what-you-use, aka the little tool that goes through your C and C++ source files and analyzes your #includes. it's giving "your header hygiene coach" and honestly? we're obsessed. πŸ¦‹


✨ NAME ✨

include-what-you-use β€” analyze #includes in C and C++ source files πŸ’…


🌸 DESCRIPTION 🌸

here's the vibe, the whole usage situation, keep it in your notes:

USAGE: include-what-you-use [-Xiwyu --iwyu_opt]... <clang opts> <source file>

so basically you pass IWYU-specific options through with -Xiwyu, and here are the <iwyu_opts> you can specify (like, for example, -Xiwyu --verbose=3). no cap, this is the full list πŸ‘‡

  • --check_also=<glob> β€” tells iwyu to print iwyu-violation info for all files matching the given glob pattern, on top of the default behaviour (which is reporting for the input .cc file and its associated .h files). 🫢 you can pass this flag multiple times if you want to specify multiple glob patterns, she's flexible like that.
  • --keep=<glob> β€” tells iwyu to always keep these includes. πŸ’– and yes, this flag can also be specified multiple times to specify multiple glob patterns.
  • --mapping_file=<filename> β€” gives iwyu a mapping file. that's it, that's the whole thing πŸŽ€
  • --no_default_mappings β€” do not add iwyu's default mappings. bye default mappings πŸ‘‹
  • --pch_in_code β€” mark the first include in a translation unit as a precompiled header. use --pch_in_code to prevent IWYU from removing necessary PCH includes, okay? 😭 though Clang forces PCHs to be listed as prefix headers, the PCH-in-code pattern can be used with GCC and is standard practice on MSVC (e.g. stdafx.h). iconic messy cross-compiler lore fr fr.
  • --prefix_header_includes=<value> β€” tells iwyu what to do with in-source includes and forward declarations involving prefix headers. so a prefix header is a file included via the command-line option -include. and if that prefix header makes an include or forward declaration obsolete, the presence of such an include can be controlled with the following values:
    • add: new lines are added ✨
    • keep: new lines aren't added, existing are kept intact 🫢
    • remove: new lines aren't added, existing are removed πŸ’€
    • default value is add. periodt.
  • --transitive_includes_only β€” do not suggest that a file add foo.h unless foo.h is already visible in the file's transitive includes. no sneaky invisible headers bestie πŸ™ˆ
  • --max_line_length β€” maximum line length for includes. note that this only affects comments and alignment thereof β€” the maximum line length can still be exceeded with long file names (default: 80). she's trying her best, okay?? 😭
  • --comment_style=<level> β€” set verbosity of 'why' comments to one of the following values:
    • none: do not add 'why' comments
    • short: 'why' comments do not include namespaces
    • long: 'why' comments include namespaces
    • default value is short. πŸ’…
  • --no_comments β€” do not add 'why' comments. silent mode, mysterious queen πŸŽ€
  • --update_comments β€” update and insert 'why' comments, even if no #include lines need to be added or removed. glow-up your comments for no reason at all, we support it πŸ’–
  • --no_fwd_decls β€” do not use forward declarations. we're going the long way, apparently πŸšΆβ™€οΈ
  • --verbose=<level> β€” the higher the level, the more output. the more she talks, the more you learn iykyk πŸ”₯
  • --quoted_includes_first β€” when sorting includes, place quoted ones first. quoted girls to the front πŸ’…βœ¨
  • --cxx17ns β€” suggests the more concise syntax introduced in C++17. modern, forward-thinking, lowkey stunning 🌈
  • --error[=N] β€” exit with N (default: 1) for iwyu violations. she's MAD now 😀
  • --error_always[=N] β€” always exit with N (default: 1) (for use with make -k). consistent drama, every single time πŸ’€
  • --debug=flag[,flag...] β€” debug flags (undocumented). spooky. mysterious. no notes πŸ™ˆ
  • --regex=<dialect> β€” use specified regex dialect in IWYU:
    • llvm: fast and simple (default) ⚑
    • ecmascript: slower, but more feature-complete ✨
  • --experimental=flag[,flag...] β€” enable experimental features:
    • clang_mappings: use Clang canonical standard library mappings instead of built-in mappings 🧚

and in addition to IWYU-specific options, you can specify the following options without the -Xiwyu prefix 🫢:

  • --help β€” prints this help and exits. she's helpful and she leaves, queen behaviour πŸ‘‘
  • --version β€” prints version and exits. πŸ’œ
⚠️ real talk though: all those --iwyu_opts need to be sent through with -Xiwyu (except the last two, --help and --version, which go in bare), so don't be out here typing them raw and then acting surprised when clang yells at you. 😭

and that's the whole page bestie, thanks for reading my manual page essay πŸŽ€ this was include-what-you-use version 8.23-1build1, dated January 2026, written under the User Commands section of the manual β€” mwah, go fix your includes, ily πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from