Enable mingw64 swig problem

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Enable mingw64 swig problem

Ilan Schnell
Hello,
I'm trying to compile Enable on 64-bit Windows using the
mingw64.  I've already fixed a few small problems, and now
I get the following compile error in some swig generated code:

g++ -g -DDEBUG -DMS_WIN64 -mno-cygwin -O0 -Wall
-DNUMPY_VERSION="\"1.4.0\"" -DNUMPY -DPY_ARRAY_TYPES_PREFIX=NUMPY_CXX
-DOWN_DIMENSIONS=0 -DOWN_STRIDES=0 -Ienthought\kiva\agg\src
-Ienthought\kiva\agg\agg-24\include
-Ienthought\kiva\agg\agg-24\font_freetype
-Ienthought\kiva\agg\freetype2\src\autofit
-Ienthought\kiva\agg\freetype2\src\base
-Ienthought\kiva\agg\freetype2\src\bdf
-Ienthought\kiva\agg\freetype2\src\cache
-Ienthought\kiva\agg\freetype2\src\cff
-Ienthought\kiva\agg\freetype2\src\cid
-Ienthought\kiva\agg\freetype2\src\gxvalid
-Ienthought\kiva\agg\freetype2\src\gzip
-Ienthought\kiva\agg\freetype2\src\lzw
-Ienthought\kiva\agg\freetype2\src\otvalid
-Ienthought\kiva\agg\freetype2\src\pcf
-Ienthought\kiva\agg\freetype2\src\pfr
-Ienthought\kiva\agg\freetype2\src\psaux
-Ienthought\kiva\agg\freetype2\src\pshinter
-Ienthought\kiva\agg\freetype2\src\psnames
-Ienthought\kiva\agg\freetype2\src\raster
-Ienthought\kiva\agg\freetype2\src\sfnt
-Ienthought\kiva\agg\freetype2\src\smooth
-Ienthought\kiva\agg\freetype2\src\tools
-Ienthought\kiva\agg\freetype2\src\truetype
-Ienthought\kiva\agg\freetype2\src\type1
-Ienthought\kiva\agg\freetype2\src\type42
-Ienthought\kiva\agg\freetype2\src\winfonts
-Ienthought\kiva\agg\freetype2\src\gzip
-Ienthought\kiva\agg\freetype2\include
-Ienthought\kiva\agg\freetype2\src
-IC:\Python26\lib\site-packages\numpy\core\include
-IC:\Python26\include -IC:\Python26\PC -c
build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp
-o build\temp.win-amd64-2.6\Release\build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.o
build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:
In function 'PyObject* _wrap_GetDC(PyObject*, PyObject*)':
build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:3539:39:
error: cast from 'HDC__*' to 'long int' loses precision

Does anyone have an idea what might be going on, or how
to tell HDC__ to have the correct type?

- Ilan
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Enable mingw64 swig problem

Robert Kern
On Wed, Nov 24, 2010 at 3:53 PM, Ilan Schnell <[hidden email]> wrote:
> Hello,
> I'm trying to compile Enable on 64-bit Windows using the
> mingw64.  I've already fixed a few small problems, and now
> I get the following compile error in some swig generated code:

> In function 'PyObject* _wrap_GetDC(PyObject*, PyObject*)':
> build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:3539:39:
> error: cast from 'HDC__*' to 'long int' loses precision
>
> Does anyone have an idea what might be going on, or how
> to tell HDC__ to have the correct type?

You need to change the code in plat_support.i to use ssize_t instead
of long. Also, use PyLong_FromSsize_t/PyLong_AsSsize_t instead of
PyLong_FromLong/PyLong_AsLong.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless
enigma that is made terrible by our own mad attempt to interpret it as
though it had an underlying truth."
  -- Umberto Eco
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Enable mingw64 swig problem

Peter Wang
In reply to this post by Ilan Schnell
On Wed, Nov 24, 2010 at 3:53 PM, Ilan Schnell <[hidden email]> wrote:
> In function 'PyObject* _wrap_GetDC(PyObject*, PyObject*)':
> build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:3539:39:
> error: cast from 'HDC__*' to 'long int' loses precision
>
> Does anyone have an idea what might be going on, or how
> to tell HDC__ to have the correct type?

Yes, the problem is that we have a swig typemap in plat_support.i that
maps HDC to Long:

%typemap(in) HDC
{
    $1 = ($1_ltype) PyLong_AsLong($input);
    if (PyErr_Occurred()) SWIG_fail;
}

I would guess that with the 64-bit of wx, the HDC is a long long, and
we will need to modify the typemap appropriately.

These are used by the draw() method, defined/shadowed in
plat_support.i, which takes the output of window_dc.GetHDC() as its
first argument.


-Peter
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Enable mingw64 swig problem

Ilan Schnell
Thanks Robert, making your suggested change fixed it.
I'll check it in once I've verified that everything works.

- Ilan


On Wed, Nov 24, 2010 at 4:03 PM, Peter Wang <[hidden email]> wrote:

> On Wed, Nov 24, 2010 at 3:53 PM, Ilan Schnell <[hidden email]> wrote:
>> In function 'PyObject* _wrap_GetDC(PyObject*, PyObject*)':
>> build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:3539:39:
>> error: cast from 'HDC__*' to 'long int' loses precision
>>
>> Does anyone have an idea what might be going on, or how
>> to tell HDC__ to have the correct type?
>
> Yes, the problem is that we have a swig typemap in plat_support.i that
> maps HDC to Long:
>
> %typemap(in) HDC
> {
>    $1 = ($1_ltype) PyLong_AsLong($input);
>    if (PyErr_Occurred()) SWIG_fail;
> }
>
> I would guess that with the 64-bit of wx, the HDC is a long long, and
> we will need to modify the typemap appropriately.
>
> These are used by the draw() method, defined/shadowed in
> plat_support.i, which takes the output of window_dc.GetHDC() as its
> first argument.
>
>
> -Peter
> _______________________________________________
> Enthought-Dev mailing list
> [hidden email]
> https://mail.enthought.com/mailman/listinfo/enthought-dev
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: Enable mingw64 swig problem

Ilan Schnell
So, it all works now.  I tested it both 32 and 64-bit (gcc and MSVC).
One has to explicitly tell swig that the #if SIZEOF_SIZE_T has to go
into the wrapper file.  This can be done by "%#if".  See:
http://www.swig.org/Doc1.3/Preprocessor.html#Preprocessor_nn9

- Ilan

On Wed, Nov 24, 2010 at 4:10 PM, Ilan Schnell <[hidden email]> wrote:

> Thanks Robert, making your suggested change fixed it.
> I'll check it in once I've verified that everything works.
>
> - Ilan
>
>
> On Wed, Nov 24, 2010 at 4:03 PM, Peter Wang <[hidden email]> wrote:
>> On Wed, Nov 24, 2010 at 3:53 PM, Ilan Schnell <[hidden email]> wrote:
>>> In function 'PyObject* _wrap_GetDC(PyObject*, PyObject*)':
>>> build\src.win-amd64-2.6\enthought\kiva\agg\src\win32\plat_support_wrap.cpp:3539:39:
>>> error: cast from 'HDC__*' to 'long int' loses precision
>>>
>>> Does anyone have an idea what might be going on, or how
>>> to tell HDC__ to have the correct type?
>>
>> Yes, the problem is that we have a swig typemap in plat_support.i that
>> maps HDC to Long:
>>
>> %typemap(in) HDC
>> {
>>    $1 = ($1_ltype) PyLong_AsLong($input);
>>    if (PyErr_Occurred()) SWIG_fail;
>> }
>>
>> I would guess that with the 64-bit of wx, the HDC is a long long, and
>> we will need to modify the typemap appropriately.
>>
>> These are used by the draw() method, defined/shadowed in
>> plat_support.i, which takes the output of window_dc.GetHDC() as its
>> first argument.
>>
>>
>> -Peter
>> _______________________________________________
>> Enthought-Dev mailing list
>> [hidden email]
>> https://mail.enthought.com/mailman/listinfo/enthought-dev
>>
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev