C / C ++:检测多余#包括? [英] C/C++: Detecting superfluous #includes?

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

问题描述

我经常发现文件的标题部分获得较大和较大所有的时间,但它永远不会变小。整个源文件类的生命可能感动,被重构,这是非常可能的,也有相当多的#包括不需要是那里了。留给他们那里只延长编译时间,增加了不必要的编译依赖。试图找出它们仍然需要可以是相当繁琐的。

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

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