Subject: Re: missing #include ?
To: Pavel Cahyna <pavel@NetBSD.org>
From: Hauke Fath <hauke@Espresso.Rhein-Neckar.DE>
List: tech-userlevel
Date: 12/10/2006 23:33:00
At 23:02 Uhr +0100 10.12.2006, Pavel Cahyna wrote:
>On Sun, Dec 10, 2006 at 09:45:39PM +0100, Hauke Fath wrote:
>> With the way unix includes are done traditionally, the #include is
>> unconditional. Even if <sys/types.h> has been pulled in two dozen times
>> before by other headers, cpp will still read the file once more, just to
>> ignore its content.
>
>"CPP optimizes even further. It remembers when a header file has a wrapper
>`#ifndef'. If a subsequent `#include' specifies that header, and the macro
>in the `#ifndef' is still defined, it does not bother to rescan the file
>at all."

I thought about that, since the preprocessor is the obvious place for an
optimisation, and ISTR C++ does something similar with the #import
statement. But I wasn't sure whether cutting corners like this would go
down well with ANSI C. If it does, all the better.

>(http://gcc.gnu.org/onlinedocs/gcc-4.1.1/cpp/Once_002dOnly-Headers.html)

They don't mandate naming conventions on the #define, do they? The text
isn't entirely clear on that.

	hauke

--
"It's never straight up and down"     (DEVO)