On 24/06/12 01:47, Aleks Kissinger wrote:
Any idea why calling symbols from certain shared libraries would cause poly/ML to crash on OS X? Example:
val gtk = load_lib "libgtk-quartz-2.0.dylib";
val gtk = ?: dylib
val gtk_init = call2 (load_sym gtk "gtk_init") (INT,INT) VOID;
val gtk_init = fn: int * int -> unit
gtk_init(0,0);
[1] 96630 killed rlwrap -z poly
It doesn't completely surprise me that this crashes: gtk_init has the signature
void gtk_init (int *argc, char ***argv);
so you're using the conversion INT for passing a pointer. INT is same size as the C int, which is likely to be 32 bits on a 64 bit platform. However, on a 64 bit platform, a pointer should be 64 bits. I suspect that this, possibly along with different calling conventions, might cause the variation you see between platforms.
The conversion LONG will give you the C long, usually the same size as a pointer, but you really want to be using the conversions POINTER or POINTERTO for passing pointers.
Out of interest, are you attempting to use GTK+ from SML?
Phil