Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2001:
[Freeciv-Dev] Re: int -> void*, was Re: [RFC] Attaching information to o
Home

[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]
To: David Pfitzner <dwpfitzner@xxxxxxxxx>
Cc: freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: int -> void*, was Re: [RFC] Attaching information to objects
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 18 Jan 2001 09:32:27 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxxxx

On Wed, Jan 17, 2001 at 07:11:00PM -0800, David Pfitzner wrote:
> Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx> wrote: 
> 
> > On Mon, Jan 15, 2001 at 03:11:08PM -0800, David Pfitzner wrote:
> 
> > > 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?
> 
> > 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
> 
> Well, I don't think Freeciv actually uses/requires C99 features
> at this time :-)

Configure can maybe teached to recgonize that intptr_t is available.

> Also this sounds like still a different problem, since it talks
> of casting pointers to int and back, where we're interested in
> casting arbitrary ints to pointers (specifically void*) and back.

So sizeof(int)<=sizeof(intptr_t). If you choose
sizeof(int)==sizeof(intptr_t) there will be no trouble either way.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "Reality? That's where the pizza delivery guy comes from!"



[Prev in Thread] Current Thread [Next in Thread]