There is always an "-H" option for gcc / g ++ ...
For example:% g ++ -H foo.C
'-H'
Print the name of each header file used, in addition to other
normal activities. Each name is indented to show how deep in the
'#include' stack it is. Precompiled header files are also
printed, even if they are found to be invalid; an invalid
precompiled header file is printed with '...x' and a valid one
with '...!' .
Then:
- 'sed' or 'awk' to remove the leading "...".
- 'so that neighboring addresses match.
- 'uniq -c' for counting names.
- 'grep -v' to remove singlets.
How in:
% g++ -H foo.C |& awk '{print $2}' | sort | uniq -c | grep -v ' 1 '
Linuxux'/unix' ?
( cygwin.)