查找冗余#includes以缩短编译时间 [英] finding redundant #includes to shorten compile time
问题描述
是否有任何C工具可以在项目中找到冗余的#includes,
以缩短编译时间?当然,消除单个
#include手工并确定重新编译是否失败是一个
选项,虽然这是一个非常手动和时间密集的
方法。谢谢,
-
本杰明
Are there any C tools that can find redundant #includes in a project,
so as to shorten compile time? Of course, eliminating single
#includes by hand and determining if the recompile fails is one
option, though that is an extremely manual and time-intensive
approach. Thanks,
--
Benjamin
推荐答案
Benjamin Rutt< br *** *****@bloomington.in.us>写在
新闻:wc ************* @ mu.cis.ohio-state.edu:
Benjamin Rutt <br********@bloomington.in.us> wrote in
news:wc*************@mu.cis.ohio-state.edu:
是有没有可以在项目中找到冗余#includes的C工具,
以缩短编译时间?当然,消除单个
#include手动并确定重新编译是否失败是一个
选项,尽管这是一个非常手动和时间密集的方法。谢谢,
Are there any C tools that can find redundant #includes in a project,
so as to shorten compile time? Of course, eliminating single
#includes by hand and determining if the recompile fails is one
option, though that is an extremely manual and time-intensive
approach. Thanks,
这个技巧将消除多次包括同一个文件每个
编译:
/ * foo.h
* /
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
/ * foo.h文件内容
*
#endif / * FOO_H_INCLUDED * /
-
- 马克 - >
-
This trick will eliminate including the same file multiple times per
compile:
/* foo.h
*/
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
/* foo.h file contents
*
#endif /* FOO_H_INCLUDED */
--
- Mark ->
--
" Mark A. Odell" <无**** @ embeddedfw.com>写道:
"Mark A. Odell" <no****@embeddedfw.com> writes:
这个技巧将消除包含同一个文件多次
编译:
/ * foo.h
* /
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
/ * foo.h文件内容
*
#endif / * FOO_H_INCLUDED * /
This trick will eliminate including the same file multiple times per
compile:
/* foo.h
*/
#ifndef FOO_H_INCLUDED
#define FOO_H_INCLUDED
/* foo.h file contents
*
#endif /* FOO_H_INCLUDED */
谢谢,对不起,我知道这个伎俩,我很少见到没有它的
a头文件。 ..我猜我错了我的问题。我实际上是在谈论#includeing文件你根本不需要,
甚至不是一次,所以我使用''冗余''是不正确的。我应该有
问:
如何找到一个单独使用的头文件
编译单元,可以安全地从.c文件中删除吗?
-
本杰明
Thanks, I''m sorry, I knew of that trick actually, and I''ve rarely seen
a header file without it...I guess I misstated my question. I was
actually talking about #includeing files that you don''t need at all,
not even once, so my using ''redundant'' was incorrect. I should have
asked:
How do you find which header files aren''t used at all by a single
compilation unit, and can safely be deleted from a the .c file?
--
Benjamin
本杰明Rutt写道:
Benjamin Rutt wrote:
如何找到单个
编译单元根本不使用哪些头文件,并且可以安全地从.c文件中删除?
How do you find which header files aren''t used at all by a single
compilation unit, and can safely be deleted from a the .c file?
我认为这属于lint的主题。例如声明未使用的
变量,什么都不做的代码块(即if(0 == 1){[...]}等等),
多余的东西(a = 1; a = 5),以及随着项目的发展累积
的所有其他垃圾。
我会使用一个lint检查器。
我使用了Gimpel lint检查器( www.gimpel.com )非常成功,
我确定还有其他的包括免费的。
-
gabriel
I believe this falls under the topic of "lint," such as declaring unused
variables, code blocks that do nothing (ie "if (0 == 1) {[...]}", etc...),
redundant stuff ("a = 1; a = 5"), and all the other junk that accumulates
as projects evolve.
I would use a lint checker for that.
I have used the Gimpel lint checker (www.gimpel.com) quite successfully,
I''m sure there are others including free ones.
--
gabriel
这篇关于查找冗余#includes以缩短编译时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!