Swig and Octave under Windows (mingw64) / long is only 32 bit

"Helmut Zeisel" <[email protected]>
Newsgroups gmane.comp.programming.swig
Message-ID <trinity-3c361f9a-ff73-42ae-8b10-ae8ed6e16c91-1563774086413@3c-app-gmx-bs61>

I tried creating some oct file for Octave under Windows (mingw64).
SWIG was installed using msys2 ( msys2-x86_64-20190524.exe );
 pacman -S mingw64/mingw-w64-x86_64-swig
octave was installed from binaries ( octave-5.1.0-w64-installer )
 
I created the wrapper file "xxx_wrap.cxx" using
 
swig -octave -c++
 
and then compiled with
 
mkoctfile  xxx_wrap.cxx
 
Then I get the error message
 
xxx_wrap.cxx: In member function 'long int octave_swig_type::swig_this() const':
xxx_wrap.cxx:1380:16: error: cast from 'const octave_swig_type*' to 'long int' loses precision [-fpermissive]
  return (long) this;
                ^~~~
xxx_wrap.cxx:1381:37: error: cast from 'void*' to 'long int' loses precision [-fpermissive]
       return (long) types[0].second.ptr;
 
When I manually change from "long" to "long long" in xxx_wrap.cxx it compiles fine and creates a working .oct file:
 
    long long swig_this() const {
      if (!types.size())
    return (long long) this;
      return (long long) types[0].second.ptr;
    }
 
As I understand, the problem is that in mingw64-gcc "long" is only 32 bit (for Visual C++ compatibility), but pointers are 64 bit.
 
Is there a SWIG version/option to fix this automatically?
 
Helmut


_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.