Detecting superfluous #includes in C/C++?(在 C/C++ 中检测多余的#include?)
问题描述
我经常发现文件的标题部分一直在变大,但从未变小.在源文件的整个生命周期中,类可能已经移动和重构,并且很可能有很多 #includes
不再需要存在.将它们留在那里只会延长编译时间并添加不必要的编译依赖项.试图找出仍然需要哪些可能非常乏味.
I often find that the headers section of a file get larger and larger all the time but it never gets smaller. Throughout the life of a source file classes may have moved and been refactored and it's very possible that there are quite a few #includes
that don't need to be there and anymore. Leaving them there only prolong the compile time and adds unnecessary compilation dependencies. Trying to figure out which are still needed can be quite tedious.
是否有某种工具可以检测多余的#include 指令并建议我可以安全删除哪些指令?
lint 可能会这样做吗?
Is there some kind of tool that can detect superfluous #include directives and suggest which ones I can safely remove?
Does lint do this maybe?
推荐答案
不是自动的,而是doxygen将为 #included
文件生成依赖关系图.您将不得不直观地浏览它们,但它们对于了解什么使用什么非常有用.
It's not automatic, but doxygen will produce dependency diagrams for #included
files. You will have to go through them visually, but they can be very useful for getting a picture of what is using what.
这篇关于在 C/C++ 中检测多余的#include?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 C/C++ 中检测多余的#include?


- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 近似搜索的工作原理 2021-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- 从python回调到c++的选项 2022-11-16
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 静态初始化顺序失败 2022-01-01
- STL 中有 dereference_iterator 吗? 2022-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- C++ 协变模板 2021-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01