Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!sdd.hp.com!spool.mu.edu!caen!zaphod.mps.ohio-state.edu!qt.cs.utexas.edu!yale.edu!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.std.c Subject: Re: so how do I do it? (was Re: call to revolt) Message-ID: <16561@smoke.brl.mil> Date: 27 Jun 91 20:20:01 GMT References: <1991Jun27.115736.18417@tkou02.enet.dec.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <1991Jun27.115736.18417@tkou02.enet.dec.com> diamond@jit533.enet@tkou02.enet.dec.com (Norman Diamond) writes: >>and then (struct foo *)p->c or (struct foo *)p->u >This is legal. Actually, no. ((struct foo *)p)->c is the way to write this. You want to cast the pointer, not the char member. >>this is nonportable, as to my understanding, as struct arrangements are not >>guaranteed. >Huh? Oh, you mean that the buffer was laid out by some other entity >than your C program. I don't know exactly what he meant (could have been any of several things), but the problems are: (1) there might be padding between the struct members and (2) the representation, especially of the unsigned member, may not agree with the C implementation's. The first problem is easy; the second one is harder.