Re: Patch for definition of NULL



Tim,

Sorry for the delay in responding to your last post.  I also didn't
realise that a bug had been filed
about this.  For anyone who wants to look at it:

    http://bugzilla.gnome.org/show_bug.cgi?id=54730

My rationale for including stddef.h was not for definitions of size_t
and ssize_t.  I am aware that ssize_t is not included everywhere.  My
concern here is that the definition of NULL in glib is not what Forte
C expects.

The existing definition does not work becuase __cplusplus is not
defined. Thus NULL is defined as (void*)0.  For whatever reason, and I
don't claim to understand it, Forte doesn't like that definition.  Its a
compiler issue, not an OS issue.

Forte will complain, and stop with an error, when compiling glib.  It
seems that problems occur wherever GDestroyNotify is used.  Anytime that
a cast is done to provide a GDestroyNotify that it breaks unless each
potential value is cast individually.  For example, the following errors
are
generated due to the fact the the uncast NULL is being used at the lines
mentioned:

"ghash.c", line 107: warning: argument #3 is incompatible with
prototype:
 prototype: pointer to function(pointer to void) returning void :
"../glib/ghash.h", line 44
 argument : pointer to void
"ghash.c", line 107: warning: argument #4 is incompatible with
prototype:
 prototype: pointer to function(pointer to void) returning void :
"../glib/ghash.h", line 44

This error causes the make to fail.  If stddef.h is included at the top
of ghash.c, before glib.h, the problem goes away.  If its included after
glib.h the problem remains.

Including stddef.h, as Owen suggested, seems to be the cleanest
solution.  I'm just not sure where to include it.  According to
gmacros.h other header files shouldn't really be included there, but I'm
not sure that this extends to system headers.  A good place might be the
top of glib.h, because then application developers can be sure that they
are getting the same definition of NULL that the library was compiled
with.  Given that stddef.h is a standard, ISO defined, header file this
shouldn't be a problem.

Thanks,

Mark


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











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