Article View: comp.lang.c++.moderated
Article #55Re: Tool for removing surplus #includes
From: Nasser Abbasi
Date: Tue, 27 Feb 1996 10:26
Date: Tue, 27 Feb 1996 10:26
77 lines
3157 bytes
3157 bytes
In article <4gj0p3$lp0@solutions.solon.com>, tonyh@tcp.co.uk says...
>
>Does anyone know of a PD tool available with portable(ish) source for
>removing surplus #include directives? For example:
>
>/* "file2.h" */
>#include "file1.h"
>
>-------------------
>
>/* "file3.h" */
>#include "file1.h"
>#include "file2.h"
>
>-------------------
>
>#include "file1.h" could be removed from "file3.h". This sort of thing
>saves a lot of compiler time without having the chore of typing:
>
>#ifndef __file1_h
>#include "file1.h"
>#endif
>
So, you mean that in the future if you decide that file2.h do not
need to include file1.h any more, you have to somehow remember
to go back to file3.h and add a line to include file1.h, since may
be file3.h needs file1.h but file2.h do not need file1.h
Having to deal with these sort of things will most likley be not worth
the effort. Also remember that all this work with including .h files
is done by the pre-processor, not by the compiler itself.
>
>I know I will still need to do:
>
>/* "file1.h" */
>#ifndef __file1_h
>#define __file1_h
>/* Body of file */
>#endif
>
>but having an additional check around any #include directives or not
>doing the include at all saves the compiler lots of time having to load
>a file it's already included.
>
I think you are trying to save few nanoseconds here from the
pre-processor time, but you will end up instead wasting more time
later when things break during compiling becuase you somewhere
have removed an include statment from one .h file that another file
needed becuase the other file has including the file that removed the
include statment from and it has assumed that that file will be there
but it is not in there any more.
You also have to remember to "run" this tool every time befor you run
the compiler, which means more tools to woorry about and manage and the
build environment will get more complicated.
If I where you, I'll have each .h file include every .h file that it
needs. If one of the files it includes happen to include one of the
files allready, then that is what #ifdef stuff for.
Now, others might think this tool is a good idea, I think it is not.
IMHO .
Nasser
{ I removed comp.lang.c.moderated from the newsgroups line as crosspostig
is currently under review -mod}
[ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
[ Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm ]
[ Moderation policy: http://www.connobj.com/cpp/guide.htm ]
[ Comments? mailto:c++-request@netlab.cs.rpi.edu ]
Technical Details
Message-ID:
<4gum81$hlk@netlab.cs.rpi.edu>Path:
arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mailReferences:
<4gj0p3$lp0@solutions.solon.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!library.erc.clarkson.edu!rpi!not-for-mail From: nababs@qualcomm.com (Nasser Abbasi) Newsgroups: comp.lang.c++.moderated,comp.lang.c++,comp.lang.c Subject: Re: Tool for removing surplus #includes Date: 27 Feb 1996 10:26:09 -0000 Organization: Qualcomm Inc. Sender: cppmods@netlab.cs.rpi.edu Approved: devitto@ferndown.ate.slb.com Message-ID: <4gum81$hlk@netlab.cs.rpi.edu> References: <4gj0p3$lp0@solutions.solon.com> NNTP-Posting-Host: netlab.cs.rpi.edu X-Original-Date: 23 Feb 1996 05:12:31 GMT