[Dynamite] ANSI C question
Ewan Birney
birney@ebi.ac.uk
Thu, 23 Mar 2000 13:29:02 +0000 (GMT)
On Wed, 22 Mar 2000, Ian Holmes wrote:
> GLib uses casts to implement "private" data, e.g.
>
> struct _GArray
> {
> gchar *data;
> guint len;
> };
>
> in "glib.h", which is then casted to
>
> struct _GRealArray
> {
> guint8 *data;
> guint len;
> guint alloc;
> guint elt_size;
> guint zero_terminated : 1;
> guint clear : 1;
> };
>
> Do either of you know if this is strict ANSI, i.e. can we be sure that the
> first two fields of _GArray (data & len) are mapped to the same memory
> locations as data and len in _GRealArray in all C compilers?
This is strict ANSI interestingly. (read the back of K&R about struct
layout).
>
> If so it makes life a lot easier...
This trick is what GTK uses for inheritance.
>
> Ian
>
> --
> Ian Holmes .... Howard Hughes Medical Institute .... ihh@fruitfly.org
>
>
> _______________________________________________
> Dynamite mailing list - Dynamite@bioperl.org
> http://www.bioperl.org/mailman/listinfo/dynamite
>
-----------------------------------------------------------------
Ewan Birney. Mobile: +44 (0)7970 151230
<birney@ebi.ac.uk>
-----------------------------------------------------------------