Alignment issues and SPARC (commentary)
Gary Wisniewski
gary at apexepa.UUCP
Thu May 26 01:14:34 AEST 1988
In article <7959 at brl-smoke.ARPA> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>In article <326 at apexepa.UUCP> gary at apexepa.UUCP (Gary Wisniewski) writes:
>> 2. I regretted making some assumptions about the viability of
>> memcpy(buf, (char *)&h, sizeof(h));
>> where 'h' is anything but a char.
>
>What's the problem? memcpy() certainly does not require any particular
>alignment of the data it copies. (Overlaps may yield surprises, though.)
My original posting contained an unfortunate transposition of ideas.
I intended to say:
2. I regretted making some assumptions about the viability of
*((type*)buf) = h;
where 'type' is not the type of 'h'.
Sounds better, doesn't it? The memcpy construction is, of course, portable
unless the format of 'buf' is in question (memcpy a structure to a char buf,
then extract items separately--naughty.)
Sorry for any confusion or alarm.
--
Gary J. Wisniewski Apex Software Corporation
{allegra,bellcore,cadre}!pitt!darth!apexepa!gary Phone: (412) 681-4343
More information about the Comp.lang.c
mailing list