Subject: Re: problems with arpa/inet.h
To: None <current-users@NetBSD.ORG>
From: Olaf Seibert <>
List: current-users
Date: 06/09/1998 12:31:00
In <> Alan Barrett <> writes:

>Mike Long <> said:
>> Multiple inclusion protection does not keep cpp from reading the whole
>> header each time it is #included. 
>This is just a SMOP.  Nothing prevents the compiler from noticing when a
>file consists entirely of comments, blank lines, and lines that are
>wrapped in a single #if or #ifdef block, keeping a record of the relevant
>#if or #ifdef conditions, testing those conditions when you try to
>#include the same file again, and deciding not to bother opening the file
>at all if the conditions are such that including the file would not be
>--apb (Alan Barrett)

And in fact, cccp (gnu's cpp) already does this. From the file,
node Once-Only:

   The standard way to do this is to enclose the entire real contents
of the file in a conditional, like this:

     #ifndef FILE_FOO_SEEN
     #define FILE_FOO_SEEN
     #endif /* FILE_FOO_SEEN */

   The GNU C preprocessor is programmed to notice when a header file
uses this particular construct and handle it efficiently.  If a header
file is contained entirely in a `#ifndef' conditional, then it records
that fact.  If a subsequent `#include' specifies the same file, and the
macro in the `#ifndef' is already defined, then the file is entirely
skipped, without even reading it.

___ Olaf 'Rhialto' Seibert                D787B44DFC896063 4CBB95A5BD1DAA96 
\X/ * You are not expected to understand this.