Related articles |
---|
Looking for header inclusion clean-up tool wprager@ca.newbridge.com (Walter Prager) (1998-08-10) |
Re: Looking for header inclusion clean-up tool wy2lam@undergrad.math.uwaterloo.ca (Michael Lam) (1998-08-13) |
Re: Looking for header inclusion clean-up tool dhansen@btree.com (1998-08-13) |
Re: Looking for header inclusion clean-up tool derek@knosof.co.uk (1998-08-13) |
Re: Looking for header inclusion clean-up tool mambuhl@tiac.net (Martin Ambuhl) (1998-08-16) |
From: | dhansen@btree.com (Dave Hansen) |
Newsgroups: | comp.lang.c++,comp.compilers,comp.lang.c |
Date: | 13 Aug 1998 22:02:10 -0400 |
Organization: | B-Tree Systems, Inc. |
References: | 98-08-064 |
Keywords: | C, tools |
On 10 Aug 1998 23:18:20 -0400, Walter Prager
<wprager@ca.newbridge.com> wrote:
>Has anyone out there heard of a tool which would assist in cleaning-up
>header inclusion? I.e. something that goes off, works for a few hours
>(days?) then produces a list of which #include's are not necessary.
PC-lint from Gimpel software almost does this. When you lint a file,
it will provide you a list of files that were included, but none of
whose definitions or declarations were used.
It's not foolproof, however. In the simplified (and contrived)
example below, some of the definitions in a.h require values defined
in b.h, so a.h #include's b.h. E.g.:
---b.h
typedef unsigned char Byte;
---end b.h
---a.h
#include "b.h"
#define MSG "Hello World"
#define Flip(b) (Byte)(~(b))
---end a.h
---main.c
#include <stdio.h>
#include "a.h"
int main(void)
{
puts(MSG);
}
---end main.c
In this example, PC-lint will complain that b.h was included, but
never used. Which is true, I guess. PC-lint would not make this
complaint if main.c were to use the Flip macro.
However, I've always been quite pleased with PC-lint, and am always
willing to praise it. I speak as a happy customer, with no link to
Gimpel software.
Regards,
-=Dave
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.