pointer -> long conversion
dmk at lanl-a.UUCP
dmk at lanl-a.UUCP
Wed Jul 11 06:08:55 AEST 1984
[]
You should be able to get both types of conversion by saying
either
anytype *x;
long i;
i = (long)((int) x); /* giving sign extension, or */
i = (long)((unsigned) x); /* no sign extension */
but I'm not sure which one is better to use as the default when you say,
i = (long)x;
-- it depends on whether you think of an address as just a token (unsigned)
or an integer (signed). Maybe it's best to just do whatever is the most
natural for the machine involved and if the user needs to force it one
way or the other then let him use a double typecast as above.
David Keaton
Los Alamos National Laboratory
ucbvax!lbl-csam!lanl-a!dmk
dmk at lanl.arpa
More information about the Comp.lang.c
mailing list