Header file analyzer?

M

Marcus Kwok

Is there a free program available that will analyze a program's source
code and tell if all necessary standard headers have been included?
Since the standard headers can include other standard headers (and as I
understand it, this is implementation defined), this would aid in
porting programs from one compiler to another. It would also be nice if
it could see if you included a standard header that never gets used.
 
M

mlimber

Marcus said:
Is there a free program available that will analyze a program's source
code and tell if all necessary standard headers have been included?
Since the standard headers can include other standard headers (and as I
understand it, this is implementation defined), this would aid in
porting programs from one compiler to another. It would also be nice if
it could see if you included a standard header that never gets used.

I'm not sure of a free program, but you might try PC-Lint from Gimpel
software (www.gimpel.com), which at least can tell you if a header
(standard or otherwise) is unnecessary in some particular source file.
It doesn't do exactly what you're looking for, but it might be of some
help.

Cheers! --M
 
M

Marcus Kwok

mlimber said:
I'm not sure of a free program, but you might try PC-Lint from Gimpel
software (www.gimpel.com), which at least can tell you if a header
(standard or otherwise) is unnecessary in some particular source file.
It doesn't do exactly what you're looking for, but it might be of some
help.

Thanks. I've used lint on linux before (one of my classes in college
provided it for us) but since software is not our main focus (I am the
only developer in our section, of 4 people) I was hoping there was some
free utility so that we could keep our budget down.
 
G

Greg

Marcus said:
Is there a free program available that will analyze a program's source
code and tell if all necessary standard headers have been included?
Since the standard headers can include other standard headers (and as I
understand it, this is implementation defined), this would aid in
porting programs from one compiler to another. It would also be nice if
it could see if you included a standard header that never gets used.

The C++ compiler itself is all that is needed for the first task. Every
time the project is built the compiler analyzes the program's source
code and will indicate if any headers, standard or otherwise, are
missing by the errors it reports. And if the project builds without the
compiler reporting any errors, then all necessary headers have been, by
definition, included.

I can definitely see the value in a utility that detected unnecessary
headers. The compiler usually isn't of much help in reporting those.

Greg
 
M

Marcus Kwok

Greg said:
The C++ compiler itself is all that is needed for the first task. Every
time the project is built the compiler analyzes the program's source
code and will indicate if any headers, standard or otherwise, are
missing by the errors it reports. And if the project builds without the
compiler reporting any errors, then all necessary headers have been, by
definition, included.

Not entirely. As an example, the current project I am working on must
run on both Windows and HP-UX. In one file, I define

std::eek:stream& operator<<(std::eek:stream& o, const MyClass& p);

On Windows I only had to include <string> and <vector>, but on HP-UX I
also had to include <iostream> (I may have gotten away with <ostream>).
It is these kinds of dependencies that I wish to find.
 
J

Jonathan Mcdougall

Marcus said:
Not entirely. As an example, the current project I am working on must
run on both Windows and HP-UX. In one file, I define

std::eek:stream& operator<<(std::eek:stream& o, const MyClass& p);

On Windows I only had to include <string> and <vector>, but on HP-UX I
also had to include <iostream> (I may have gotten away with <ostream>).
It is these kinds of dependencies that I wish to find.

In this case, a good reference book, Dinkumware and the standard are
your friends.


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top