Read the GCC option summary. Then read about the GCC preprocessor options. Read also about precompiled headers (conceptually, it is just some cache). They have limitations that I explained here.
Why can't you use -H
and filter, perhaps by some script using grep
or awk
, its output? You could also use some -M*
option.
Otherwise, you might write your own GCC plugin. It would use the PLUGIN_INCLUDE_FILE
event.
My opinion is that writing a plugin for just that information is overkill.
At last, GCC is free software. You are allowed to get its source code and improve it (I am not sure it is worth the effort to understand the internals of GCC for just your purposes). You probably should publish your improvements under GPLv3+ (but that is an ethical or legal or open source licensing question, so off-topic here; be aware of the GCC runtime library exception). You could pay some GCC expert to do the work for you.
Future C++20 (or later) might have modules (see also this and read p1103r0). Of course, you'll need a more recent GCC than the old GCC 7. You could need to wait for GCC 10 or later.
Maybe you should look at other languages, e.g. Rust, Go, or Ocaml.