Path: utzoo!attcan!uunet!husc6!bbn!rochester!pt.cs.cmu.edu!cadre!pitt!darth!apexepa!gary From: gary@apexepa.UUCP (Gary Wisniewski) Newsgroups: comp.lang.c Subject: Re: Alignment issues and SPARC (commentary) Summary: Correction to previous posting Message-ID: <327@apexepa.UUCP> Date: 25 May 88 15:14:34 GMT References: <326@apexepa.UUCP> <7959@brl-smoke.ARPA> Reply-To: gary@apexepa.UUCP (Gary Wisniewski) Organization: Apex Software Corp., Pittsburgh, Pa. Lines: 25 In article <7959@brl-smoke.ARPA> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <326@apexepa.UUCP> gary@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