For instance when we have the following C file:
#include <time.h>
struct tm x;
iwyu
generates the following garbage output:
zsh % iwyu 99-tmp.c
99-tmp.c should add these lines:
#include <bits/types/struct_tm.h> // for tm
99-tmp.c should remove these lines:
- #include <time.h> // lines 1-1
The full include-list for 99-tmp.c:
#include <bits/types/struct_tm.h> // for tm
---
[1] 12133 exit 4 iwyu tmp.c
Which is totally nonsense. <time.h>
is defined to have struct tm
in ISO C since forever (cf: ISO/IEC 9899:2018 section 7.27).
struct tm
is not the only entity that iwyu
miss; for another instance max_align_t
is missing. Not to mention other entities in POSIX and C++.
This tool is worse than being useless. The suggestion miserably breaks portability. Just trash it.
In order for
iwyu
to become a non-toy, IMO it should leave all#include <foo>
-style lines as-is and focus on#include "foo"
, or at least understand#pragma gcc system_header
to ignore symbols from such files.