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: rf13@xxxxxxxxxxxxxxxxxxxxxxxx
Cc: David Pfitzner <dwpfitzner@xxxxxxxxx>, freeciv development list <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: int -> void*, was Re: [RFC] Attaching information to objects
From: Gaute B Strokkenes <gs234@xxxxxxxxxxxxxxxx>
Date: 18 Jan 2001 12:12:29 +0000

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;

-- 
Big Gaute                               http://www.srcf.ucam.org/~gs234/
Uh-oh --  WHY am I suddenly thinking of a VENERABLE religious leader
 frolicking on a FORT LAUDERDALE weekend?



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