TC2.0 bugfree ?
Scott "The Pseudo-Hacker" Neugroschl
abcscnge at csuna.UUCP
Mon Jan 23 05:20:32 AEST 1989
In article <15560 at mimsy.UUCP> chris at 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!!!
More information about the Comp.lang.c
mailing list