You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm using IWYU currently at my workplace and I've run into an issue. The software I am building supports various mutually exclusive targets set by compiler flags. For example, I might build the software with -DTARGET_A or -DTARGET_B.
Currently, I apply the iwyu_tool.py tool with a compilation database.
The issue is, if I am building the software with -DTARGET_A, iwyu suggests the removal of #include's that are only required by -DTARGET_B. Is there any support for combining the results of iwyu when build under multiple compiler flag sets and only removing includes if they are needed for none of the options?
After invoking <path to binary>/include-what-you-use test_file.cpp -DTARGET_A=1 it gives the following output:
test_file.cpp should add these lines:
test_file.cpp should remove these lines:
- #include <array> // lines 2-2
The full include-list for test_file.cpp:
#include <vector> // for vector
---
After invoking <path to binary>/include-what-you-use test_file.cpp -DTARGET_B=1 it gives the following output:
test_file.cpp should add these lines:
test_file.cpp should remove these lines:
- #include <vector> // lines 3-3
The full include-list for test_file.cpp:
#include <array> // for array
---
Is there any support or tooling to support applying iwyu recommendations across multiple runs with various compiler flag settings?
The text was updated successfully, but these errors were encountered:
This is my personal opinion, but I would suggest wrapping #include directives with appropriate #ifdef directives. Some people think it's ugly, I don't mind. You probably need to do a similar thing with uses of v and a to avoid "unused variable" warnings. Unless, of course, if their scope is very limited and fits inside one #ifdef with a declaration.
Without going into specifics I can't build the software with more than one target enabled at a time so @kimgr that idea is sadly not possible.
@i-ky's idea is interesting. Sadly, it would require a major refactor of our codebase to guard target specific includes with preproccessor directives so I don't think that's possible for me either.
Hi, I'm using IWYU currently at my workplace and I've run into an issue. The software I am building supports various mutually exclusive targets set by compiler flags. For example, I might build the software with
-DTARGET_A
or-DTARGET_B
.Currently, I apply the
iwyu_tool.py
tool with a compilation database.The issue is, if I am building the software with
-DTARGET_A
,iwyu
suggests the removal of#include
's that are only required by-DTARGET_B
. Is there any support for combining the results ofiwyu
when build under multiple compiler flag sets and only removing includes if they are needed for none of the options?As a mini example, take the following file:
After invoking
<path to binary>/include-what-you-use test_file.cpp -DTARGET_A=1
it gives the following output:After invoking
<path to binary>/include-what-you-use test_file.cpp -DTARGET_B=1
it gives the following output:Is there any support or tooling to support applying
iwyu
recommendations across multiple runs with various compiler flag settings?The text was updated successfully, but these errors were encountered: