X-Authentication-Warning: acp3bf.physik.rwth-aachen.de: broeker owned process doing -bs Date: Wed, 8 Mar 2000 14:51:20 +0100 (MET) From: Hans-Bernhard Broeker X-Sender: broeker AT acp3bf To: Eli Zaretskii cc: djgpp-workers AT delorie DOT com Subject: Re: iso646.h and some questions In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp-workers AT delorie DOT com Errors-To: dj-admin AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk [...] > > > > > > #undef NULL > > > > > > #define NULL 0 > Wrong command. It misses these two lines from stdlib.h: > > /* Some programs think they know better... */ > #undef NULL I knew we always #undef it before #define NULL 0, as you can see in the quoted fragment above. But on closer inspection, I think that doesn't really solve the problem either. [...] > reason turned to be that the C++ compiler has its own definition > of NULL, pulled from some C++ header. That figures. But it also means that depending on the order of C and C++ header #include's, C++ will still break, I think. I haven't tested it, here (no DJGPP at hand), but if the last #include in a C++ program is, say, , C++ will barf because NULL is now defined as 0, instead of the __null it wants. So the current method is still not a full solution, either. Let me propose an alternative that should always work. Introduce a new file, to keep it tightly organized. Lets call it : --- new file --- /* Decorate with #ifndef multi-inclusion catcher, and 'extern "C"', as * pleases... */ #ifdef __cplusplus # define _DJ_NULL __null /* C++ wants this, for 'NULL' */ #else # define _DJ_NULL 0 /* C needs this, instead */ #endif --- end file --- Then, all the #undef NULL #define NULL 0 sequences in the C standard headers could be replaced by #include #ifndef NULL #define NULL _DJ_NULL #endif This should work for both C and C++ compiles. Or doesn't the C++ __null evaluate to a C-usable NULL pointer constant, if passed to an extern "C" function? Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.