Murga-Projects Forums

Full Version: build problems on amd64
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm trying to build murgalua on an amd64, but the following cast

lua_getref(S, (int) udata);

fails to compile

bind-fltk.cxx: In function ‘int lua_call1_fl_ask(lua_State*)’:
bind-fltk.cxx:8940: warning: ‘fl_ask’ is deprecated (declared at /usr/include/FL/fl_ask.H:59)
bind-fltk.cxx:8940: warning: ‘fl_ask’ is deprecated (declared at /usr/include/FL/fl_ask.H:59)
bind-fltk-ext.cxx: In function ‘void lua_fltk_widget_callback(Fl_Widget*, void*)’:
bind-fltk-ext.cxx:37: error: cast from ‘void*’ to ‘int’ loses precision
make[2]: *** [bind-fltk-ext.o] Error 1
Hi, maybe your compiler is set too pedantic.
Try setting the -fms-extensions and -fpermissive compiler flags
Are you using GCC via MingW ?

Tobi Wrote:
Hi, maybe your compiler is set too pedantic.
Try setting the -fms-extensions and -fpermissive compiler flags
Are you using GCC via MingW ?


Or maybe the compiler is right (At least with the error message).

If I remember correctly (I have currently no such machine at hand), the size of int is 32 bit on amd64 (with gcc) and the size of void* is of course 64bit. Therefore the cast is wrong. It looks like the code is not 64 bit clean (at least not on AMD64 with gcc), because it makes some assumptions that are not always true.

Juergen Wrote:
If I remember correctly (I have currently no such machine at hand), the size of int is 32 bit on amd64 (with gcc) and the size of void* is of course 64bit. Therefore the cast is wrong. It looks like the code is not 64 bit clean (at least not on AMD64 with gcc), because it makes some assumptions that are not always true.


Yes, this is exactly what is happening -- trying to store a 64-bit pointer in a 32-bit int. I was thinking about creating a C++ container to map a unique integer to the udata pointer.

Reference URL's