从一个cpp给出头文件列表和使用的hpp文件

时间:2018-05-20 15:40:54

标签: c++ header-files code-organization

我想列出与这个.cpp文件相关的所有头文件和.h文件。 该列表还需要包含子头文件,.hpp文件和date文件。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

我不确定你的意思是"头文件"。

但您可能会发现以下内容非常有用。 (我的makefile中有。)

  

.PHONY:depend .depends:* .hh $(CC)$(CC_FLAGS)-M * .cc> .depends

它在我命名为" .depends"的文件中生成大量信息。

HelloWorld.cc是10行。

依赖贡献的典型输出:

HelloWorld.o: HelloWorld.cc /usr/include/stdc-predef.h \
 /usr/include/c++/7/iostream \

...

 /usr/include/c++/7/bits/basic_ios.tcc \
 /usr/include/c++/7/bits/ostream.tcc /usr/include/c++/7/istream \
 /usr/include/c++/7/bits/istream.tcc

总行数约为1870年。

使用g ++ v7.2.0,ubuntu 17.10(64)