On Tue, Sep 13, 2005 at 07:27:52PM +0200, Andreas Jochens wrote:
> On 05-Sep-13 10:52, Shaun Jackman wrote:
> > SWT 3.1 does not build on 64 bit platforms due to numerous...
> >     cast from 'void*' to 'jint' loses precision
> > ... errors [1]. The patch to fix this issue would be large, indeed.
> > I'm inclined to remove the 64 bit platforms from the list of buildable
> > architectures until this is fixed upstream. That does seem like a
> > major loss though. Would someone with a 64 bit development machine be
> > interested in supplying a patch?
> 
> Hello,
> 
> the attached patch makes swt-gtk compile on 64 bit architectures
> (checked on amd64 and ppc64). It replaces type conversions of pointers
> to (jint) with type conversions to (long).

Pretty please stop using longs as something that can hold a
pointer.  In general you should not cast a pointer to any integer
type.  If you really have to, use an intptr_t type.

> @@ -141,7 +141,7 @@
>  {
>       jint rc = 0;
>       XPCOM_NATIVE_ENTER(env, that, PR_1Malloc_FUNC);
> -     rc = (jint)PR_Malloc(arg0);
> +     rc = (long)PR_Malloc(arg0);

So you avoid an error by first casting it from a pointer to a
long and then casting it (implicitly) to an jint (int) instead of
doing it with only 1 cast?  Of course this will now compile, but
how useful is this if it doesn't run?

I'm happy g++ considers casting a pointer to an int as an error.
Too bad gcc only gives a warning about it.  But it doesn't help
if people just "shut up the warning".

Anyway, jint is defined in /usr/include/mozilla/jri_md.h (from
mozilla-dev) as:
#ifdef IS_64 /* XXX ok for alpha, but not right on all 64-bit architectures */
typedef unsigned int    juint;
typedef int                             jint;
#else
typedef unsigned long   juint;
typedef long                    jint;
#endif

Which looks rather strang to me.


Kurt



-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to