Complete.Org: Mailing Lists: Archives: freeciv-ai: December 2004:
[freeciv-ai] Re: (PR#9610) autosettler "territory" and danger maps

[freeciv-ai] Re: (PR#9610) autosettler "territory" and danger maps

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Subject: [freeciv-ai] Re: (PR#9610) autosettler "territory" and danger maps
From: "Russ Lewis" <webmaster@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 19 Dec 2004 10:44:21 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: >

Why not just define a typedef:
    typedef <someIntType> intPtr;
Then, early in main(), you doublecheck that
    sizeof(void*) == sizeof(intPtr)

You'll get a failure the first time that you try to run on a platform 
where it doesn't you know immediately that you have to fix the 
typedef for that platform.

Of course, if you can do the check at compile time, that would be 
better...can an #if statment make that comparison?

Jason Short wrote:

><URL: >
>You can't cast an int as a void* and treat it as a pointer.  This won't work 
>on 64-bit systems 
>where sizeof(int) != sizeof(void*).  (Or so I'm told; I've never actually 
>compiled on a 64-bit 
>There are two choices (unless you want to redesign the movemap to hold unit 
>directly and work properly with deletions).  Probably the better one is to 
>and keep the unit ID in a malloced pointer.  Naturally you then have to free 
>the pointer 
>afterwards.  The other is to develop our own version of G_POINTER_TO_INT/
>G_INT_TO_POINTER that could probably just be copied verbatim from the glib 
>Naturally then we have to make sure this macro works on any new systems that 
>turn up in 
>the future.

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