>>>> "cgw" == Charles G Waldman
<cgw(a)pgt.com> writes:
cgw> Should these #includes just get patched into the source, or
cgw> should it be taken care of by "configure"?
Source files that use features should #include the headers that define
those features. We already assume an ANSI compiler, which guarantees
that <stddef.h> will be provided.
cgw> The windowing system in question is the version of CDE that came with
cgw> Solaris 2.5. It has a /usr/openwin/include/X11/Xlib.h that reads like
cgw> this:
cgw> #ifndef X_WCHAR
cgw> #include <stddef.h>
cgw> #else
cgw> /* replace this with #include or typedef appropriate for your system */
cgw> typedef unsigned long wchar_t;
cgw> #endif
cgw> That is the only occurence of "stddef.h" in Xlib.h. So I suppose I
cgw> have X_WCHAR getting defined from somewhere else, and that's keeping
cgw> stddef.h from being indirectly included.
cgw> But it seems that files that use "ptrdiff_t" should not be counting on
cgw> some kind of indirect inclusion of stddef.h, they should just go ahead
cgw> and include it.
Correct. We are in violent agreement.
The patch is trivial, and should really be added to XEmacs 21.0, since
it is very safe:
(I was probably guilty of adding a use of ptrdiff_t to alloc.c)
(malloc.c probably isn't used any more, but it can't hurt to add the #include)
Obpatch:
1998-10-08 Martin Buchholz <martin(a)xemacs.org>
* src/alloc.c:
* src/unexec.c:
* src/malloc.c:
Add <stddef.h> to get ptrdiff_t declaration
--- src/alloc.c.orig Thu Oct 8 23:47:09 1998
+++ src/alloc.c Thu Oct 8 23:47:23 1998
@@ -56,6 +56,8 @@
#include "sysfile.h"
#include "window.h"
+#include <stddef.h>
+
#ifdef DOUG_LEA_MALLOC
#include <malloc.h>
#endif
--- src/unexec.c.orig Thu Oct 8 23:47:40 1998
+++ src/unexec.c Thu Oct 8 23:47:57 1998
@@ -190,6 +190,7 @@
# define __STDC_EXTENDED__ 1
# endif
+# include <stddef.h>
# include <stdlib.h>
# include <unistd.h>
# include <string.h>
--- src/malloc.c.orig Thu Oct 8 23:48:10 1998
+++ src/malloc.c Thu Oct 8 23:48:29 1998
@@ -166,6 +166,8 @@
#endif /* not emacs */
+#include <stddef.h>
+
/* Define getpagesize () if the system does not. */
#include "getpagesize.h"