如何递归列出源文件或头文件包含的所有 C++ 头文件

使用 C 预处理器列出包含:

gcc_includes_cmd.sh
gcc -E -M myfile.c

输出如下:

gcc_includes_output.txt
myfile.o: myfile.c header1.h /usr/include/stdio.h /usr/include/stdlib.h

对于递归列出,使用 -M-MM 选项。你也可以编写小脚本将输出解析为列表。


Check out similar posts by category: C/C++