NULL in stddef.h as seen from other C++ parsing tools

Dirk Duellmann Dirk.Duellmann@cern.ch
Wed Mar 3 10:17:00 GMT 1999


This might be a bit of topic of this mailing list but seeing the discussion of
how to define NULL, there are some additional problem with the current egcs:

If one uses another C++ parser on the current library headers it will
currently get NULL defined as (void *)0 and typically signals syntax errors
later on (e.g. in iostream's uses of NULL).

This other parser in our case is a schema capture tool which parses
definitions of persistent classes for an object database (and therefore
has to parse any other header files used to define these persistent 
classes).

To make this parser work with the egcs release we had to patch 
stdef.h and guard the NULL definition in there using __cplusplus 
to get NULL defined as 0  for the schema parser:

#if defined (_STDDEF_H) || defined (__need_NULL)
#undef NULL		/* in case <stdio.h> has defined it. */
#ifdef __GNUG__
#define NULL __null
#else   /* G++ */
/* shield NULL definition for non-gnu parsers */
>>new<< #ifndef __cplusplus
>>new<< #define NULL ((void *)0)
>>new<< #else
>>new<< #define NULL 0
>>new<< #endif  /* __cplusplus */
#endif  /* G++ */
#endif	/* NULL not defined and <stddef.h> or need NULL.  */
#undef	__need_NULL

I guess a guard of some form should probably go into the release
stddef.h as well to allow for non-egcs parsing which might happen
also from other sw tools.


	Cheers, Dirk
-- 
------------------------------------------------------------
Dirk Duellmann		Tel : +41 22 767 4937
IT Division 513 1-007	Fax : +41 22 767 8630 
CERN			Mail: Dirk.Duellmann@cern.ch
CH-1211 Geneva 23	WWW:  http://home.cern.ch/~dirkd


More information about the Gcc mailing list