如何查找包含标题的位置?

时间:2022-07-17 06:26:39

I'm having some nasty error with one header file being included with different linkages (namely, stdio.h with and withoun "extern C"). So, I need to find where one specific header file is included.

我在一个头文件中出现了一些令人讨厌的错误,其中包含了不同的链接(即stdio)。h with和withoun“extern C”)。因此,我需要找到包含一个特定头文件的地方。

I am aware of doxygen but unfortunately the header I'm interested is stdio.h, which is also included by Qt. So the only way (that I'm familiar with) to use doxygen - is to scan entire Qt folder. That could take forever.

我知道doxygen,但不幸的是,我感兴趣的标题是stdio。h,也包括Qt,所以使用doxygen的唯一方法是扫描整个Qt文件夹。这可能需要很长时间。

So, is it possible to find out, where one header is included, without drawing include graphs for every headers in the project? Or is there some other way of solving this?

那么,是否可以找到一个标题包含的地方,而不包括项目中每个头的图形?或者还有其他的解决方法吗?

2 个解决方案

#1


2  

You can try gcc -E to preprocess the file and see where the header file comes from;

您可以尝试gcc -E来预处理该文件,并查看头文件的来源;

Or you can just search your -Ipath where the header file is.

或者你可以搜索你的-Ipath文件头文件。

#2


0  

I'd use grep:

我使用grep:

grep --color --binary-files=without-match -R -n -i "stdio.h" *

grep——颜色——二进制文件=不匹配-R -n -i“stdio”。h”*

that will recursively search down a tree, examining every text file for stdio.h, printing each match with the file name and line number where it was found.

这将递归搜索树,检查每个文本文件。h,打印每个匹配的文件名和行号。

#1


2  

You can try gcc -E to preprocess the file and see where the header file comes from;

您可以尝试gcc -E来预处理该文件,并查看头文件的来源;

Or you can just search your -Ipath where the header file is.

或者你可以搜索你的-Ipath文件头文件。

#2


0  

I'd use grep:

我使用grep:

grep --color --binary-files=without-match -R -n -i "stdio.h" *

grep——颜色——二进制文件=不匹配-R -n -i“stdio”。h”*

that will recursively search down a tree, examining every text file for stdio.h, printing each match with the file name and line number where it was found.

这将递归搜索树,检查每个文本文件。h,打印每个匹配的文件名和行号。