On 06-Aug-2002, Alastair Reid <[EMAIL PROTECTED]> wrote: > > Andrew J Bromage <[EMAIL PROTECTED]> writes: > > This number is called the "alignment", and a good rule of thumb for > > computing it is: > > > instance Storable a where alignment a = sizeOf a `min` machine_word_size > > The way we calculate it in GHC and Hugs is: > > #define offsetof(ty,field) ((size_t)((char *)&((ty *)0)->field - (char *)(ty *)0))
You shouldn't define offsetof() yourself. The C standard provides offsetof() in <stdlib.h> -- you should use that rather than defining it yourself. Defining offsetof() yourself is an error if <stdlib.h> is included, because you are stepping on the implementation's namespace. Furthermore, the definition there is not standard-conforming C code, since it dereferences a null pointer. -- Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit The University of Melbourne | of excellence is a lethal habit" WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp. _______________________________________________ Haskell mailing list [EMAIL PROTECTED] http://www.haskell.org/mailman/listinfo/haskell