如何快速调试C++包含文件问题
我们经常遇到这样的问题,如下所示:
1>Compiling...
1>a.cpp
1>c:\apps\b.h(22) : fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory
有时,由于一个大项目中有许多包含文件,甚至嵌套的包含文件,这可能会很乏味。
跟踪/哪个包含文件是包含有问题的包含文件的罪魁祸首(父级)的最佳方法是什么?
问题是它有嵌套的包含,所以需要花费一些努力才能知道哪个文件实际包含 bh
Very often we encounter this kind of issues like below:
1>Compiling...
1>a.cpp
1>c:\apps\b.h(22) : fatal error C1083: Cannot open include file: 'boost/shared_ptr.hpp': No such file or directory
Sometimes it could be tedious as there a many include files and even nested include files in a big project.
What is the best way to trace / which include file is the culprit(parent) that include the problematic include file?
The problem is it has nested include, so will need to spend some effort before able to tell which file actually include b.h.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来您使用的是 Windows(因此可能使用 Microsoft C/C++ 编译器)。在这种情况下,您可以使用 /showIncludes 选项。另请参阅此SO答案。
这使您可以“直观地”查看哪个头文件包含哪个头文件,从而为您提供更多信息。
更新:显然 GCC 有一些类似的选项。
Looks like you're on Windows (thus maybe using Microsoft C/C++ compiler). In that case you can use the /showIncludes Option. Also see this SO answer.
This allows you to "visually" see which header file includes which, giving you some more information.
Update: Apparently GCC has some similar options.
Autotools有这个功能。您可以检查某些头文件是否存在。我确信其他构建工具也具有类似的功能...
Autotools has this feature. You can check whether certain header files are present or not.. I'm sure other build tools have similar features...