On 6/1/2012 2:17 PM, Osmo Antero wrote:

> I have couple of C structures that I want to distinguish between by
> reading the structures' first (type) field.  [...]
> 
> Q:  Can I assume that the "type" field is always first in the
> structures, so I can read it with: NodeType type = *(NodeType*)node;

Yes.  Structure members are stored in the order in which they're
defined, and a pointer to a structure also points to its first member
(suitably cast).  This is guaranteed by the C standards.

> but can I trust it on all *nix plattforms and GCC compilers.

Anything that's standards-compliant.

- Ernie                                  http://home.comcast.net/~erniew

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to