可以包含哪些文件?

2 c

我希望能够获得C源文件中包含的所有可能文件的列表.

我知道其他#指令也有并发症(例如,#ifdef可以阻止包含或引起额外的包含).我正在寻找的是可能已包含的文件列表.

有没有一个工具已经这样做了?

我正在编译的文件只是.o,标准C库不包括在内.我知道这听起来不错,但我们有理由.

我希望能够做到这一点的原因是我想要一个可能对.o有贡献的文件列表,所以我可以查看它们是否已经改变.

sth*_*sth 10

引用手册页gcc:

-M  Instead of outputting the result of preprocessing, output a rule
    suitable for make describing the dependencies of the main source
    file.  The preprocessor outputs one make rule containing the object
    file name for that source file, a colon, and the names of all the
    included files, including those coming from -include or -imacros
    command line options.
Run Code Online (Sandbox Code Playgroud)

这基本上做你想要的.还有其他几个相关选项(均以...开头-M)为您提供此输出的不同变体.