简体   繁体   English

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

[英]how to quickly debug C++ include file problems

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 bh 问题是它有嵌套包含,因此需要花费一些精力才能告诉哪个文件实际包含bh

Looks like you're on Windows (thus maybe using Microsoft C/C++ compiler). 看起来你在Windows上(因此可能使用Microsoft C / C ++编译器)。 In that case you can use the /showIncludes Option. 在这种情况下,您可以使用/ showIncludes选项。 Also see this SO answer . 另见这个SO答案

This allows you to "visually" see which header file includes which, giving you some more information. 这允许您“直观地”查看哪个头文件包含哪些,为您提供更多信息。

Update: Apparently GCC has some similar options . 更新:显然GCC有一些类似的选择

Autotools has this feature. Autotools具有此功能。 You can check whether certain header files are present or not.. I'm sure other build tools have similar features... 您可以检查某些头文件是否存在。我确定其他构建工具具有类似的功能......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM