Explanation, please!
Jabir Hussain
jabir at quintus.uucp
Fri Sep 2 06:00:35 AEST 1988
In article <9064 at pur-ee.UUCP> hankd at 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
More information about the Comp.lang.c
mailing list