By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,905 Members | 1,267 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,905 IT Pros & Developers. It's quick & easy.

Header file analyzer?

P: n/a
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.

--
Marcus Kwok
Oct 24 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Marcus Kwok wrote:
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

Oct 24 '05 #2

P: n/a
> Marcus Kwok wrote:
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.

mlimber <ml*****@gmail.com> wrote: 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.

--
Marcus Kwok
Oct 24 '05 #3

P: n/a

Marcus Kwok wrote:
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

Oct 24 '05 #4

P: n/a
> Marcus Kwok wrote:
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.

Greg <gr****@pacbell.net> wrote: 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::ostream& operator<<(std::ostream& 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.

--
Marcus Kwok
Oct 24 '05 #5

P: n/a
Marcus Kwok wrote:
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::ostream& operator<<(std::ostream& 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

Oct 24 '05 #6

P: n/a
>> Marcus Kwok wrote:
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::ostream& operator<<(std::ostream& 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.
Jonathan Mcdougall <jo***************@gmail.com> wrote:
In this case, a good reference book, Dinkumware and the standard are
your friends.


That's what I suspected, though I was hoping otherwise. Thanks.

--
Marcus Kwok
Oct 24 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.