I want to find out whether my C++ code(set of files)
include some unused header files, do you know of any
free static checker in linux for the job ?
Regards,
Chinmoy
Welcome to the club!
:-)
From gcc manpage, what about the -Wunsed-macros. Apparently it gives a
warning for each unused macro. Not sure if this works for the inclusion
macros in the header files (#ifndef FILE_H #define FILE_H ... #endif). But
perhaps it will give some hints?
--
Alvin
Think about your proposal again ;-)
How about grep?
If the header file isn't being used, then it has not been #include'd
anywhere. Simply search for the name of the header file in your source.
The ones you don't find are not used.
- Jay
... or you simply forgot that there is a subdirectory with source files
which actually might use them...
Besides, including a header doesn't necessarily constitute "using". What
if none of the constructs declared/defined in that header are ever used?
V
> Jay Nabonne wrote:
>> On Fri, 29 Apr 2005 14:41:46 +0530, Chinmoy Mukherjee wrote:
>>
>
> ... or you simply forgot that there is a subdirectory with source files
> which actually might use them...
Well, grep -r :)
>
> Besides, including a header doesn't necessarily constitute "using". What
> if none of the constructs declared/defined in that header are ever used?
>
Yep. How the OP meant "using" was a little unclear. Other answers
went in the "nothing in the file is used" direction. I thought I'd throw
that option out, just in case that happened to be what the OP meant.
- Jay
this will work and its not that bad, because you can skip the header you
know are required and consentrate on the others.
I wonder if a compiler plugin could be run overnight to automate this
process, if one could be built
millions of compiling-hours a day could be saved by world-wide developers.
Carl
"Chinmoy Mukherjee" <a17...@motorola.com> wrote in message
news:4271FA52...@motorola.com...
> for every cpp file
> for every header include
> comment out the include
> compile the cpp file
> if( compile_errors )
> un-comment out the header
> else
> remove header include from cpp
>
This is how I have had to do it. There is one caveat though: if a header
file contains #defines that control compilation paths, the source file may
compile *error-free* without the header file included, but it may compile
*differently*. So the header file would still be needed to properly
configure the compile.
- Jay