tool to check multiple inclusion of header file

T

techBoy

I am looking for a tool which can scan my source code and tell me if a
header file gets included more then once in a sequence of source file
or header files. Can some one guide me to such a tool !!
 
V

Vladimir S. Oka

I am looking for a tool which can scan my source code and tell me if a
header file gets included more then once in a sequence of source file
or header files. Can some one guide me to such a tool !!

This is off-topic here, but...

<OT>
Did you consider using `grep` to find all occurrences of #include lines
(`grep` can tell you which files they belong to, and/or their total
count, as well)? Further clever processing of the `grep` output should
be able to give you the answer you want.

There may be better ways/specialised tools, but I'm not aware of them.
</OT>
 
P

pemo

techBoy said:
I am looking for a tool which can scan my source code and tell me if a
header file gets included more then once in a sequence of source file
or header files. Can some one guide me to such a tool !!

May I ask why you want to do this? If it's because you're getting circular
references, you should perhaps use the following technique ...

#ifndef MY_HEADER_H
#define MY_HEADER_H

// MY_HEADER_H stuff here.

#endif

If it's not for that - just through curiosity, I'd be interested in knowing
the 'why'.
 
R

ranjmis

techBoy said:
I am looking for a tool which can scan my source code and tell me if a
header file gets included more then once in a sequence of source file
or header files. Can some one guide me to such a tool !!

gcc preprocessor source code may give some insight
 
R

Rod Pemberton

techBoy said:
I am looking for a tool which can scan my source code and tell me if a
header file gets included more then once in a sequence of source file
or header files. Can some one guide me to such a tool !!

You can look for check, cproto, cdecl, ctool, cxref, etc. I don't recall
which one does what. Most of these are available from comp.sources.unix or
DECUS. But, you can Google them.

comp.sources.unix, cxref is in volume1:
http://ftp.sunet.se/pub/usenet/ftp.uu.net/comp.sources.unix/

DECUS:
Index (files unavailable) http://www.decus.org/encompass/software/
Files ftp://ftp.encompassus.org/lib/


Rod Pemberton
 
T

techBoy

Yaa a header gurad is a good idea, I am already using that. Trying to
bring dwon my compilation time. So wanted to eliminate this aspect
first, and see to it that a header file doesn't get included more than
once.
 
V

Vladimir S. Oka

techBoy said:
Yaa a header gurad is a good idea, I am already using that. Trying to
bring dwon my compilation time. So wanted to eliminate this aspect
first, and see to it that a header file doesn't get included more than
once.

Quoting context is essential, especially so when you make so many
spelling mistakes that it's hard to figure out what you're saying. Read
and heed <http://cfaj.freeshell.org/google/>.
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top