Article View: comp.std.c
Article #3224Re: so how do I do it? (was Re: call to revolt)
From: Doug Gwyn
Date: Thu, 27 Jun 1991 20:20
Date: Thu, 27 Jun 1991 20:20
17 lines
1380 bytes
1380 bytes
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.
Technical Details
Message-ID:
<16561@smoke.brl.mil>Path:
arc1-ca.pugleaf.net!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!gwynReferences:
<rabson.677868220@physics.ubc.ca> <m0jspJY-0001ieC@shiva.reed.edu> <1991Jun27.115736.18417@tkou02.enet.dec.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <rabson.677868220@physics.ubc.ca> <m0jspJY-0001ieC@shiva.reed.edu> <1991Jun27.115736.18417@tkou02.enet.dec.com> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17