dce/rpc "client" api

Luke Kenneth Casson Leighton lkcl at samba.org
Fri Aug 18 05:41:26 GMT 2000


> Well, there's the X Window System's XEvent union:
> 
>   typedef union _XEvent {
>     int type;
>     XAnyEvent xany;
>     XKeyEvent xkey;
>     /*   [maybe 20 more entries]   */
>     long pad[24];
>   } XEvent;
> 
> Each of the structures in the union begins with "int type", which is
> used to determine which struct you're really dealing with.

this implies that all compilers will always start with the 1st member of
the structure at the start of the structure, namely that:

offsetof(Xevent, type) == 0.

if you can guarantee that this will always be the case, for all Xevent
unions, this is acceptable.

however, it cannot, so it is not.

p.s. if you are in contact with the X windows developers, please tell 
them i said that this is dodgy approach!





More information about the samba-technical mailing list