在C / C ++中检测多余的#includes? [英] Detecting superfluous #includes in C/C++?

查看:62
本文介绍了在C / C ++中检测多余的#includes?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我经常发现文件的标头部分一直在变大,但是从不变小。在源文件的整个生命周期中,类可能已经移动并重构了,很可能有很多 #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指令并建议我可以安全删除的指令?

棉绒可以这样做吗?

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 ++中检测多余的#includes?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆