Questions tagged [iwyu]
20 questions
74
votes
4 answers
How can I use the tool 'Include What You Use' together with CMake to detect unused headers?
The tool Include What You Use can be used to detect unneeded headers. I am using CMake for my C++ software project. How can I instruct CMake to run Include What You Use automatically on the source files of my software project?

Erik Sjölund
- 10,690
- 7
- 46
- 74
5
votes
0 answers
How treat `include-what-you-use` warnings as errors with `cmake`
Is it possible to treat include-what-you-use warnings as errors using cmake?
I am playing around with include-what-you-use trying to integrate it into our cmake build process. The desired behaviour is to stop the build process when…

Alexis Le Provost
- 1,803
- 2
- 11
- 9
5
votes
1 answer
Set CXX_INCLUDE_WHAT_YOU_USE property in CMake for every target
I have multiple CmakeLists.txt in my project and I'd like to enable iwyu.
Adding
set_property(
TARGETS MY-TARGET
PROPERTY CXX_INCLUDE_WHAT_YOU_USE ${iwyu_path}
)
would enable it for one target. I'd like to enable it for every target to avoid…

David Bensoussan
- 2,887
- 2
- 38
- 55
4
votes
3 answers
Is typedef allowed before definition
Minimum code:
// foo.h
typedef struct foo_s foo_t;
struct foo_s {
foo_t* next;
};
iwyu insists I forward declare struct foo_s before I typedef it to foo_t.
Output:
$ iwyu -c foo.h
foo.h should add these lines:
struct foo_s;
foo.h should…

user100046
- 422
- 4
- 11
3
votes
1 answer
how to make xcodebuild ignore errors
I want to use include-what-you-use with xcodebuild. The problem is when I do:
$ export CC=/path/to/include-what-you-use
$ xcodebuild
from command line, I get errors and build stops. I've read that a common way to use iwyu with make is to run make…

Pavel Davydov
- 3,379
- 3
- 28
- 41
2
votes
1 answer
include-what-you-use with non-default g++ version
I'm trying to get include-what-you-use working with my codebase for the first time.
My CentOS6 system has its default of g++ 4.4.7 installed. I use g++ 4.9.3 for my C++11 project. Those four choices are inflexible.
I effectively build the cmake…

Lance E.T. Compte
- 932
- 1
- 11
- 33
2
votes
0 answers
iwyu adding cxxabi.h for __forced_unwind
I'm running iwyu over my code base, and there are a few files where it insists I add
#include // for __forced_unwind
I was able to ablate code and find that it seems related to cv.wait(mu).
Specifically, the no predicate version.
If I…

user100046
- 422
- 4
- 11
2
votes
0 answers
Can I speed up IWYU with CCache?
I'm developing a project which uses CMake for build system generation, CCache for speeding up the build (set via CMAKE_CXX_COMPILER_LAUNCHER), and Include What You Use for tidying up the required headers (set via…

Adrian Ostrowski
- 31
- 5
2
votes
0 answers
Single-pass run of Clang tools (clang-tidy, iwyu, etc.) along with compilation?
Is there a feasible way to run Clang's various code-checking tools (like clang-tidy and include-what-you-use) together with compilation, so that the source code is only parsed and processed once (single-pass)?
I'm doing this to help compilation…

user541686
- 205,094
- 128
- 528
- 886
1
vote
1 answer
Include What You Use wants a forward declaration of a type stored in an array in a template class which results in a field has incomplete type error
eI have a template class, similar to the following class.
The behaviour is not that relevant, important is, that it has an array as attribute which stores T and its size depends on the template parameter TCapacity.
template

Sandro Koch
- 303
- 1
- 4
- 11
1
vote
2 answers
Using IWYU fix_includes.py with CMake - more friendly instuctions
I have problem running tool fix_includes.py that automatically fixes up source files based on the include-what-you-use recommendations.
I have configured IWYU tool accordingly to the documentation:
downloaded IWYU version matching my Clang…

KamilPolok
- 21
- 6
1
vote
1 answer
IWYU change selected gcc installation
Include What You Use is failing to lint files with c++ 17 headers. It reports an error that it can not find them.
When I run iwyu -v it says it is using devtoolset 7 but I have devtoolset 11 installed and I want it to use 11 instead.
$ iwyu -v
clang…

Philip Nelson
- 1,027
- 12
- 28
1
vote
0 answers
Make IWYU analyze included headers, not just main program
I have a project which I compile with
cmake .. -DCMAKE_CXX_INCLUDE_WHAT_YOU_USE="iwyu"
make
The problem is that iwyu seems to be only looking at the *.cpp files being compiled and not at headers included from the cpp itself.
What option you I pass…

alfC
- 14,261
- 4
- 67
- 118
1
vote
0 answers
Why does CMake + Include What You Use not print any output?
I have installed Include What You Use.
I cloned the repository, checked out tag 0.18 and compiled.
$ include-what-you-use -v
clang version 14.0.0 (Fedora 14.0.0-1.fc36)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir:…

steddy
- 146
- 1
- 9
1
vote
1 answer
How to use the tool include-what-you-use together with Visual Studio solution?
I have a standart Visual Studio solution and use MSVS compiler. How can I use include-what-you-use without CMake?
upd:
I used sourcetrail for make compilation_database.json from solution.
Buy iwyu_tool.py -p="path to json" doesn't work with…

Ieshir
- 31
- 7