如何分辨其中的头文件是从包括在内? [英] How to tell where a header file is included from?

查看:130
本文介绍了如何分辨其中的头文件是从包括在内?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能知道其中g ++能找到一个包含文件?基本上,如果我

How can I tell where g++ was able to find an include file? Basically if I

#include <foo.h>

G ++会扫描搜索路径,使用任何的选项包括添加或更改的路径。但是,在天结束时,有没有办法,我可以告诉大家,G ++选择编译foo.h中的绝对路径?尤其是如果有在搜索路径的无数多个foo.h中相关

g++ will scan the search path, using any include options to add or alter the path. But, at the end of days, is there a way I can tell the absolute path of foo.h that g++ chose to compile? Especially relevant if there is more than one foo.h in the myriad of search paths.

中实现这个目的的一种方法短...有没有办法让G ++来告诉我最终的搜索路径是什么,包括设置后,所有包含选项?

Short of a way of accomplishing that... is there a way to get g++ to tell me what its final search path is after including defaults and all include options?

推荐答案

这将给使依赖关系而列出包括文件的绝对路径。

This will give make dependancies which list absolute paths of include files.

gcc  -M showtime.c

如果你不希望该系统包括(即#包括LT&;&something.h GT;),然后使用

If you dont want the system includes (i.e. #include <something.h>) then use

gcc  -MM showtime.c

这篇关于如何分辨其中的头文件是从包括在内?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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