Xref: utzoo comp.sys.ibm.pc:23627 comp.lang.c:15729 Path: utzoo!attcan!uunet!husc6!bloom-beacon!bu-cs!mirror!rayssd!srhqla!csun!csuna!abcscnge From: abcscnge@csuna.UUCP (Scott "The Pseudo-Hacker" Neugroschl) Newsgroups: comp.sys.ibm.pc,comp.lang.c Subject: Re: TC2.0 bugfree ? Message-ID: <1600@csuna.UUCP> Date: 22 Jan 89 19:20:32 GMT References: <3785@druwy.ATT.COM> <16674@iuvax.cs.indiana.edu> <15560@mimsy.UUCP> Reply-To: abcscnge@csuna.UUCP (Scott "The Pseudo Hacker" Neugroschl) Organization: California State University, Northridge Lines: 40 In article <15560@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >(If you rearranged the source to read > > i = *(int *)cp; > >I would expect the latter sequence.) The problem with this construct is that it is not portable. Many machines (read 68000) require integer data to be aligned. Actually, i have in my "standard library" of home brewed routines: int intat(p) unsigned char *p; { int x = 0; x = (int)(*p) * 0x100; x += *++p; return(x); } long longat(p) unsigned char *p; { return(((long)intat(p) * 0x10000L) + (long)intat(p+2)); } /* Please note these are from memory, I think I handled sign extension woes but these are just skeletal for the idea */ Actually, these two routines aren't even completely portable because they assume a big-endian architecture. The would have to be rewritten (or ifdefed) for a little endian architecture. -- Scott "The Pseudo-Hacker" Neugroschl UUCP: ...!sm.unisys.com!csun!csuna!abcscnge -- "Beat me, whip me, make me code in Ada" -- Disclaimers? We don't need no stinking disclaimers!!!