Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2002:
[Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Building freeciv
Home

[Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Building freeciv

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: Davide Pagnin <nightmare@xxxxxxxxxx>
Cc: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: Compaq Tru64 Unix Alpha platform - Building freeciv
From: Ben Webb <ben@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 12 May 2002 20:46:07 +0100

On Sun, May 12, 2002 at 08:18:57PM +0200, Davide Pagnin wrote:
> I've managed to compile freeciv on a Alpha platform with Tru64 unix 5.1A
> (formerly Digital Unix).
> 
> I've already read that Ben Webb has the same platform (alpha) but
> It was not clear if he used linux or Tru64 Unix.

Well, you could have asked. ;) It's a RedHat 7.1 (i.e. Linux) box.

> 1) when you feed an operand to a function of the print family, with
> a format of %i or %d, gcc expects you feed a 32 bit integer, even 
> with alpha platform, so it is necessary to explicitly cast to integer
> or unsigned integer every pointer that has to be passed to such
> a function. This applies also to particular case, like the passing of
> a precision field.

        Well, it expects an argument of "int" type. This is not
necessarily a 32-bit quantity, but you're right - the compiler does
spit out warnings whenever you try passing a size_t value, since this
is of 64-bit size, while "int" is 32-bit, on the Alpha platform. There
was a discussion about this a while ago, and the general consensus (IMHO)
was that you could fix this for all cases by casting size_t to
(unsigned long) and using a %ld format, but that it wasn't really anything
worth worrying about.

> 2) When you use the XtPointer defined by Xt intrinsics, you definitely
> use a pointer, but in the present coding style of freeciv, many time
> it is necessary to convert such pointers to integers, and this is done
> by casting them to int.
> 
> This make the compiler warn of a conversion from pointer to integer
> of different size, because obviously pointers on alpha are 64 bit,
> and int are 32 bit.

        The same problem occurs with the GTK+ client. I've eliminated most
of these warnings by using the GLib macros for converting ints to and
from pointers. You may want to use something similar for Xaw. Basically,
two such macros are defined, namely

#define GPOINTER_TO_INT(p)      ((gint)  (glong) (p))
#define GINT_TO_POINTER(i)      ((gpointer) (glong) (i))

        As long as you don't accidentally try to store a "real" pointer
in an int, these macros are safe.

> Example:
> static bool is_ok_opt_name_char(char c)
> {
>   return isalnum(c);
> }
> 
> Besides ignoring this type of warning, the only solution I foresee is 
> an explicit cast to int of the c parameter, because it is not possible
> to have the string defined as arrays of unsigned char.

        I think to be sure you'd need a (int)(unsigned char)c cast here,
otherwise bad things would happen if c is a character > 128.

        Your configure problem sounds like it's Tru64-specific; at any
rate, I've not come across this problem on an Alpha Linux box, so can't
offer any useful hints here. ;)

        Ben
-- 
ben@xxxxxxxxxxxxxxxxxxxxxx           http://bellatrix.pcl.ox.ac.uk/~ben/
"Rosebud"


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