Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10.2 (MU) 9/23/84; site munnari.OZ
Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!genrad!decvax!mulga!munnari!kre
From: kre@munnari.OZ (Robert Elz)
Newsgroups: net.lang.c
Subject: Re: alignment of struxures
Message-ID: <623@munnari.OZ>
Date: Sun, 6-Jan-85 05:43:50 EST
Article-I.D.: munnari.623
Posted: Sun Jan  6 05:43:50 1985
Date-Received: Mon, 7-Jan-85 03:17:53 EST
References: <6954@brl-tgr.ARPA>
Reply-To: kre@munnari.OZ (Robert Elz)
Organization: Comp Sci, Melbourne Uni, Australia
Lines: 25

In article <6954@brl-tgr.ARPA> cottrell@nbs-vms.ARPA writes:

| 2) in the meantime, try this:
| 
| 	#define LONG(x) (*((long *)(x)))
| then
| 	struct ugly {
| 		char	a;
| 		char	longint[4];	/* really a long int */
| 		...
| 	} yuk;
| 
| to get the long int do:
| 
| 	barf = LONG(yuk.longint);

Quite apart from possibly causing "segmentation violation - core dumped"
on those hosts that like aligned longs, it's also not guaranteed to work.

Compilers are allowed to put padding "anywhere" inside a struct/union,
all they need to do is leave the order alone.  One of the compilers
I work with would put 3 bytes of padding between "a" and "longint"
in the structure above...

Robert Elz					decvax!mulga!kre