#include优化 [英] #include optimization

查看:68
本文介绍了#include优化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我目前正在维护一个代码库非常庞大的遗留代码。

我遇到了C / C ++文件出现问题很多不必要的#includes。

平均每个C / C ++文件都包含大约150+ .h文件。我发现75%的b
文件是不必要的,可以删除。考虑到我的b $ b有一个巨大的代码库,我无法手动修复它。


是否有任何工具可以报告不想要的。 h文件?


我不确定这是否是一个提出这个问题的合适组合。

如果可以提供任何指示,我将不胜感激。 />

谢谢

Ramesh

Hi,

I am currently maintaining a legacy code with a very very large code base.
I am facing problems with C/C++ files having a lot of un-necessary #includes.
On an average every C/C++ file has around 150+ .h files included. I find 75%
of the files unnecessary and could be removed. Considering the fact that I
have a huge code base, I can''t manually fix it.

Are there any tools that would report un wanted .h files?

I am not sure if this is a right group to ask this question.
I would appreciate if any pointers could be provided.

Thanks
Ramesh

推荐答案

In< 11 ***** ********************@posting.google.com> ra******@gmail.com (Ramesh)写道:
In <11*************************@posting.google.com> ra******@gmail.com (Ramesh) writes:
我目前正在维护一个代码库非常庞大的遗留代码。
我面临着很多不必要的#include的C / C ++文件的问题。
平均每个C / C ++文件包含大约150+ .h文件。我发现75%的文件是不必要的,可以删除。考虑到我有一个巨大的代码库,我无法手动修复它。
I am currently maintaining a legacy code with a very very large code base.
I am facing problems with C/C++ files having a lot of un-necessary #includes.
On an average every C/C++ file has around 150+ .h files included. I find 75%
of the files unnecessary and could be removed. Considering the fact that I
have a huge code base, I can''t manually fix it.




如果它没有被破坏,请不要解决它。


Dan

-

Dan Pop

DESY Zeuthen,RZ小组

电子邮件: Da*****@ifh.de

目前在欧盟找工作



If it ain''t broken, don''t fix it.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Currently looking for a job in the European Union





为什么#include'不想要?我会假设所包含的文件

包含#define',以防止文件中的代码比预处理器更多地加载




问候,

Peter Jansson
http: //jansson.net/

Hi,

Why are the #include''s not wanted? I would assume the included files
contain #define''s that prevent the code in the files to be loaded more
than once by the preprocessor?

Regards,
Peter Jansson
http://jansson.net/


Ramesh写道:
Ramesh wrote:


我目前正在维护一个代码库非常庞大的遗留代码。
我面临着很多不必要的#include的C / C ++文件的问题。
平均每个C / C ++文件包含大约150+ .h文件。我发现75%的文件是不必要的,可以删除。考虑到我有一个巨大的代码库,我无法手动修复它。

是否有任何工具可以报告不想要的.h文件?
<我不确定这是否是一个提出这个问题的合适组织。
如果能提供任何指示,我将不胜感激。

谢谢
Ramesh
Hi,

I am currently maintaining a legacy code with a very very large code base.
I am facing problems with C/C++ files having a lot of un-necessary #includes.
On an average every C/C++ file has around 150+ .h files included. I find 75%
of the files unnecessary and could be removed. Considering the fact that I
have a huge code base, I can''t manually fix it.

Are there any tools that would report un wanted .h files?

I am not sure if this is a right group to ask this question.
I would appreciate if any pointers could be provided.

Thanks
Ramesh




你总是可以写自己的。


你可能想要考虑这种技巧:

#ifndef HEADER_SYMBOL

#include" header_file.h"

#endif

这可以加快编译速度,无需打开

头文件,然后遇到守卫,然后读到

EOR到达守卫的尽头,并关闭文件。


但这是更多的实施质量问题。

有些编译器可能很聪明,不能打开

头文件。


-

托马斯马修斯


C ++新闻组欢迎mes圣人:
http://www.slack.net/~ shiva / welcome.txt

C ++常见问题: http://www.parashift.com/c++-faq-lite

C常见问题: http://www.eskimo.com/~scs/c-faq/top.html

alt.comp.lang.learn.c-c ++ faq:
http ://www.comeaucomputing.com/learn/faq/

其他网站:
http://www.josuttis.com - C ++ STL图书馆书籍



You could always write your own.

You may want to consider this technique:
#ifndef HEADER_SYMBOL
#include "header_file.h"
#endif
which could speed up compilation by not having to open
header files, then encounter the guard, then read until
EOR to reach the end of the guard, and close the file.

But this is more of a quality of implementation issue.
Some compilers may be smart enough not to open the
header files already.

--
Thomas Matthews

C++ newsgroup welcome message:
http://www.slack.net/~shiva/welcome.txt
C++ Faq: http://www.parashift.com/c++-faq-lite
C Faq: http://www.eskimo.com/~scs/c-faq/top.html
alt.comp.lang.learn.c-c++ faq:
http://www.comeaucomputing.com/learn/faq/
Other sites:
http://www.josuttis.com -- C++ STL Library book


这篇关于#include优化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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