[Freeciv-Dev] Re: int -> void*, was Re: [RFC] Attaching information to o
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
On Mon, Jan 15, 2001 at 03:11:08PM -0800, David Pfitzner wrote:
> Falk Hueffner <falk.hueffner@xxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> > [1] It seems when using ints as keys, the current code uses the void*
> > of the hash_bucket to point to the int, instead of stuffing the int
> > directly into the void* (which should always be at least as large as
> > an int). Is there a certain reason for this?
>
> Is it guaranteed by the language that stuffing the int into the
> void* will always work, or does it just happen to work on most
> (all?) platforms?
>
> Eg, could you have a platform on which a particular int bit pattern
> happened to be invalid as a pointer value, and the implementation
> happened to notice this at runtime and throw up its hands in horror?
See intptr_t from stdint.h. I haven't found any offical text only
<http://www.haskell.org/pipermail/cvs-ghc/2000-November/000336.html>:
ISO/ANSI C99 added optional types intptr_t and uintptr_t. Pointers
can be cast to these types and back without loss of information.
IMHO they are expected to be used in weird places where pointers
need to be stored together with integers. They are not needed for
pointer arithmetic.
Raimar
--
email: rf13@xxxxxxxxxxxxxxxxx
One nuclear bomb can ruin your whole day.
|
|