确定哪个文件包含一些特定的头文件 [英] Identify which file has included some particular header file

查看:56
本文介绍了确定哪个文件包含一些特定的头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时标头结构复杂,但有时会包含一些标头,但很难分辨从何而来.

Sometimes with a complex header structure it happens some header is included, but it is hard to tell where from.

是否有一些工具(依赖查看器?)或一种方法来查找包含堆栈"(哪个源/哪个标头/哪个标头/...)包括一个特定的标头文件?

Is there some tool (depedency viewer?) or a method how to find the "inclusion stack" (which source / which header / which header / ...) is including one particular header file?

如果头文件被多次包含,则发现第一个包含就足够了,找到所有包含项是值得欢迎的.

If the header file is included multiple times, finding first inclusion is sufficient, finding all inclusions is a welcome bonus.

推荐答案

有人对此发表了评论,但我找不到此答案. 因此,在VS中,转到项目属性.选择配置属性"/"C/C ++"/高级"/显示包含"并设置为是".

Someone has posted about it but I can't find this answer. So, In VS, go to your project properties. Choose Configuration Properties / C/C++ / Advanced / Show Includes and set "yes".

然后编译您的cpp文件.看起来像这样: cpp文件:

then compile you cpp file. It looks like this: cpp file:

#include <stdio.h>

int main()
{
    return 0;
}

在编译后的输出窗口中,您将看到:

In the output window after compiling you will see:

1>------ Build started: Project: stlport_project, Configuration: Release Win32 ------
1>Compiling...
1>stlport_project.cpp
1>Note: including file: D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stdio.h
1>Note: including file:  D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stl/_prolog.h
1>Note: including file:   D:\src\hrs_rt_059.00\HRS\modules\src\libs\src\external\stlport\5.1.7\stl/config/features.h

以此类推

引用相同的问题显示#include Visual Studio中C ++文件的层次结构

这篇关于确定哪个文件包含一些特定的头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆