Xref: utzoo comp.lang.c:12306 comp.arch:6222 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!sun!quintus!jabir From: jabir@quintus.uucp (Jabir Hussain) Newsgroups: comp.lang.c,comp.arch Subject: Re: Explanation, please! Message-ID: <339@quintus.UUCP> Date: 1 Sep 88 20:00:35 GMT References: <638@paris.ics.uci.edu> <189@bales.UUCP> <9064@pur-ee.UUCP> Sender: news@quintus.UUCP Reply-To: jabir@quintus.UUCP (Jabir Hussain) Organization: Quintus Computer Systems, Inc. Lines: 39 In article <9064@pur-ee.UUCP> hankd@pur-ee.UUCP (Hank Dietz) writes: > struct t512 { int t[512]; }; > struct t256 { int t[256]; }; [...] > if (n & 512) { > *((struct t512 *) q) = *((struct t512 *) p); q+=512; p+=512; > } [...] > Unfortunately, the above code should have been > written as: > > if (n & 512) { > *(((struct t512 *) q)++) = *(((struct t512 *) p)++); > } > ... > > but, for some unknown reason, the VAX C compiler didn't like that. one portable way around that is to do something like: typedef char *caddr_t; typedef union { struct { int t[512]; } t512; struct { int t[256]; } t256; caddr_t caddr; } ustruct_t; { register ustruct_t src,dst; src.caddr = (caddr_t) p; dst.caddr = (caddr_t) q; if (n & 512) *dst.t512++ = *src.t512++; ... } jh