Re: Patch for definition of NULL



Owen,

I agree with you.  Our workaround up to now was simply to include stddef.h
but I was under the impression that include system header files was not
desirable.  It would make things cleaner, and also allow for the underlying
OS definitions to change without having to change glib to match.

Aside from that, a lot of what's included in stddef.h is covered by ISO
standards anyway.

So should we go with #include <stddef.h>?

Mark


------------------------------
Mark Murnane
Desktop, Applications and Middleware
Sun Microsystems Ireland
------------------------------

Owen Taylor wrote:

> Mark Murnane <Mark Murnane Sun COM> writes:
>
> > Hi,
> >
> > When compiling glib with Sun's Forte compiler, we run across problems
> > with the definition of NULL.  On Solaris systems NULL is defined as
> > either 0 or 0L, depending on whether or not you're compiling 64-bit
> > binaries.  I've put a conditional define in gmacros.h which only applied
> > when Forte is being used.  Does anyone have any objections if I commit
> > this?
>
> I'm tending to thing that the right thing here is to simply include
> stddef.h to get the corrent definition of NULL. Trying to match
> all systems stddef.h with #ifdef's is a rats-nest I'd much
> prefer not to enter.
>
> Tim has expressed his opposition to this, but I can't agree. If
> someone doesn't want the fundemental basic stuff defined in stddef.h,
> they aren't going to want all the stuff the GLib headers drag in as
> well.
>
> Regards,
>                                         Owen
>
> > Index: glib/gmacros.h
> > ===================================================================
> > RCS file: /cvs/gnome/glib/glib/gmacros.h,v
> > retrieving revision 1.3
> > diff -u -r1.3 gmacros.h
> > --- glib/gmacros.h    2001/06/23 13:55:07     1.3
> > +++ glib/gmacros.h    2001/07/11 15:37:18
> > @@ -107,6 +107,15 @@
> >   *  been defined. It is assumed that if they are already
> >   *  defined then the current definition is correct.
> >   */
> > +
> > +#if !defined NULL && defined __SUNPRO_C
> > +#  if defined (_LP64) && !defined (__cplusplus)
> > +#    define NULL     0L
> > +#  else
> > +#    define NULL     0
> > +#  endif
> > +#endif
> > +
> >  #ifndef NULL
> >  #  ifdef __cplusplus
> >  #    define NULL        (0L)





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]