In earlier conversation, Juanjo seemed to suggest thatOn Sun, Feb 1, 2009 at 6:52 PM, Geo Carncross <email@example.com> wrote:
> On Sun, Feb 1, 2009 at 3:50 PM, Gabriel Dos Reis
> <firstname.lastname@example.org> wrote:
>> since intptr_t is garanteed to be precise enough to hold
>> a value of type void*.
> Well, casting it to (int) [if that causes problems] would simply truncate it
> again anyway- even though it was originally cast to intptr_t
the value there really was an int. So the truncation was OK.
My point in my preceding message is that the mapping
from void* to int is highly unportable (anyone to guess standard
semantics?), compared to the mapping from void* to intptr_t,
which although implementation-defined is guaranteed to yield
the original int value back.
My personal inclination would be to use a union of void* and int,
and select the appropriate field, thereby not depending on any
implementation defined assumption at all. That also would
make the intent clearer.