Re: Multiple Inclusion of Standard Header Files
- From: Richard Heathfield <rjh@xxxxxxxxxxxxxxx>
- Date: Sun, 14 Jan 2007 08:17:43 +0000
sam_cit@xxxxxxxxxxx said:
David T. Ashley wrote:
Are the standard header files (<stdio.h> for example) always safe to
include more than once?
Actually, many header file uses pre-processor statement
#ifndef INCLUDE
#define INCLUDE 1
...
...
...
#endif
which would take care that contents of the header are not replaced
again by the pre-processor...
Nor would any other header that used the same identifier. Fortunately, that
isn't how things are done.
You pick a *unique* name, e.g. something like:
#ifndef H_CUSTOMER_HEADER
#define H_CUSTOMER_HEADER 1
....
#endif
That way, you don't disable other headers further down the list.
--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.
- Follow-Ups:
- Re: Multiple Inclusion of Standard Header Files
- From: Malcolm McLean
- Re: Multiple Inclusion of Standard Header Files
- References:
- Multiple Inclusion of Standard Header Files
- From: David T. Ashley
- Re: Multiple Inclusion of Standard Header Files
- From: sam_cit
- Multiple Inclusion of Standard Header Files
- Prev by Date: Re: pre-processor string replacement
- Next by Date: Re: pre-processor string replacement
- Previous by thread: Re: Multiple Inclusion of Standard Header Files
- Next by thread: Re: Multiple Inclusion of Standard Header Files
- Index(es):
Relevant Pages
|