Determing alignment of (char *) pointer
David desJardins
desj at brahms
Sat Dec 6 10:20:13 AEST 1986
In article <1510 at mit-trillian.MIT.EDU> newman at athena.mit.edu (Ron Newman) writes:
> char *p;
>
> if ((long)p & 3) ...
>
> if ((long)(p - (char *) 0) & 3) ...
Why not use
if (p != (char *) (long *) p) ... ?
This should give you the relevant information (can a long be stored at
the location pointed to by p?) without any machine dependencies. I suppose
on some (broken) compilers it might not work...
-- David desJardins
More information about the Comp.lang.c
mailing list