如何判断头文件包含在哪里?

How to tell where a header file is included from?(如何判断头文件包含在哪里?)
本文介绍了如何判断头文件包含在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何知道 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?

推荐答案

这将给出列出包含文件绝对路径的make依赖:

This will give make dependencies which list absolute paths of include files:

gcc  -M showtime.c

如果您不希望系统包含(即 #include <something.h>),请使用:

If you don't want the system includes (i.e. #include <something.h>) then use:

gcc  -MM showtime.c

这篇关于如何判断头文件包含在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Rising edge interrupt triggering multiple times on STM32 Nucleo(在STM32 Nucleo上多次触发上升沿中断)
How to use va_list correctly in a sequence of wrapper functions calls?(如何在一系列包装函数调用中正确使用 va_list?)
OpenGL Perspective Projection Clipping Polygon with Vertex Outside Frustum = Wrong texture mapping?(OpenGL透视投影裁剪多边形,顶点在视锥外=错误的纹理映射?)
How does one properly deserialize a byte array back into an object in C++?(如何正确地将字节数组反序列化回 C++ 中的对象?)
What free tiniest flash file system could you advice for embedded system?(您可以为嵌入式系统推荐什么免费的最小闪存文件系统?)
Volatile member variables vs. volatile object?(易失性成员变量与易失性对象?)