Re: Multiple Inclusion of Standard Header Files



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.
.



Relevant Pages