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: 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: Fri, 19 Jan 2001 01:44:30 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxxxx

On Thu, Jan 18, 2001 at 12:12:29PM +0000, Gaute B Strokkenes wrote:
> On Thu, 18 Jan 2001, hawk@xxxxxxxxxxxxxxxxxxxxxxx wrote:
> 
> > 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.
> 
> Isn't this what unions are for?  eg.
> 
> typedef union {
>   int i;
>   void *p;
> } my_inptr_t;

All information of i can only be stored in p if sizeof(i)<=sizeof(p).

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 A life? Cool! Where can I download one?



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