- Use
IWYU pragma: keepto force IWYU to keep any#includedirective that would be discarded under its normal policies. - Use
IWYU pragma: always_keepto force IWYU to keep a header in all includers, whether they contribute any used symbols or not. - Use
IWYU pragma: exportto tell IWYU that one header serves as the provider for all symbols in another, included header (e.g. facade headers). UseIWYU pragma: begin_exports/end_exportsfor a whole group of included headers. - Use
IWYU pragma: no_includeto tell IWYU that the file in which the pragma is defined should never#includea specific header (the header may already be included via some other#include.) - Use
IWYU pragma: no_forward_declareto tell IWYU that the file in which the pragma is defined should never forward-declare a specific symbol (a forward declaration may already be available via some other#include.) - Use
IWYU pragma: privateto tell IWYU that the header in which the pragma is defined is private, and should not be included directly. - Use
IWYU pragma: private, include "public.h"to tell IWYU that the header in which the pragma is defined is private, andpublic.hshould always be included instead. - Use
IWYU pragma: friend ".*favorites.*"to overrideIWYU pragma: privateselectively, so that a set of files identified by a regex can include the file even if it's private.
The pragmas come in three different classes;
- Ones that apply to a single
#includedirective (keep,export) - Ones that apply to a file being included (
private,friend,always_keep) - Ones that apply to a file including other headers (
no_include,no_forward_declare)
Some files are both included and include others, so it can make sense to mix and match.
https://github.com/include-what-you-use/include-what-you-use/blob/master/docs/IWYUPragmas.md