Extract all included files in cpp

I have a .cpp file (text). I want to get a list of all the file names that are included (#include) in this file. What is the best way to do this? (It is necessary to implement it in C ++)

+5
source share
2 answers

gcc -M source.cpp

Replace -Mwith -MMif you are not interested in the system.

+2
source

Assuming you have find or grep, something like that:

g++ -E source.cpp | grep '\# 1 '

+1
source

All Articles