Martin Buchholz writes:
>>>>> "Colin" == Colin Rafferty
<colin.rafferty(a)msdw.com> writes:
Colin> Björn Torkelsson writes:
>> The latest version of XEmacs updated from CVS yesterday
(2000-04-03) is
>> uncompilable under SGI IRIX with the naitive SGI cc compiler.
Colin> I submitted the patch to xemacs-patches to undo Martin's changes
Colin> already. Here it is for your personal enjoyment.
Colin> 2000-03-23 Colin Rafferty <colin(a)xemacs.org>
Colin> * lisp.h (STRETCHY_STRUCT_SIZEOF): Add back.
Colin> * fns.c (size_bit_vector):
Colin> * alloc.c (size_vector):
Colin> (make_vector_internal):
Colin> (make_bit_vector_internal):
Colin> (sweep_bit_vectors_1):
Colin> Replace calls to offsetof with STRETCHY_STRUCT_SIZEOF macro.
I don't like reversing this change. Is the code in XEmacs
ANSI-compliant? I think so.
I don't. While I don't have a copy of the standard, SGI compilers are
very good at following the standards.
"/ms/user/c/craffert/proj/shadow/xemacs/xemacs-martin/src/alloc.c", line 1132:
error(1028):
expression must have a constant value
size_t sizem = offsetof (Lisp_Vector, contents[sizei]);
^
The #define is the same on SGI, Linux, and SunCC:
#define offsetof(s, m) (size_t)(&(((s *)0)->m))
Then is this a bug in SGI's compiler? If so, I'd rather not
have
code ugliness for one specific compiler, especially one so rarely
used by the development community. Instead, I would like to find a
better fix for this problem. If necessary, we add something like:
#undef offsetof
#define offsetof ...
to the sgi s&M files. Or introduce a true configure test for
broken
offsetof.
There is no valid `offsetof(s. m)' that will work on SGI. You need to
have three arguments to work. If you want, you can choose how
STRETCHY_STRUCT_SIZEOF works based on offsetof:
#ifdef EXTENDED_OFFSETOF
# define STRETCHY_STRUCT_SIZEOF(type, field, length) offsetof(type, field[length])
#else
# define STRETCHY_STRUCT_SIZEOF(type, field, length) /* current big ugly */
#endif
The principle, as I've said many times before, is
Write code compliant with standards, and add workarounds, if
necessary, to special files, especially configure and header files,
designed as portability adapters.
I agree. And I also understand using extensions if they are
ubiquitous. But I cannot think of any way to write offsetof(s, m) on
SGI.
If you would like me to cons up a configure test for offsetof, I can
write STRETCHY_STRUCT_SIZEOF (or OFFSETOF) as above. But I'm not sure
what that gives us in terms of code readability, and I don't think it
will even help performance on platforms that can call `offsetof'
directly.
--
Colin