如何快速调试C++包含文件问题

发布于 2024-11-28 07:12:56 字数 335 浏览 2 评论 0原文

我们经常遇到这样的问题,如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

才能让你更想念 2024-12-05 07:12:56

看起来您使用的是 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.

也只是曾经 2024-12-05 07:12:56

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...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文