[MLton] Callbacks

Stephen Weeks MLton@mlton.org
Thu, 15 Jan 2004 08:16:16 -0800


> I'm having trouble with callbacks of this type:
...
> (*val gKbdFA = _export "glutKeyboardFuncArgument": char * int * int -> unit;
...
> which gives an export unification error without much explanation,

Indeed.  This was a bug.  I have checked in a fix.  Hopefully you can
remake the compiler by bootstrapping on Cygwin?  That's how I build
the Cygwin package these days.

> =====================================================================
> C API:
> GLUTAPI void APIENTRY glutKeyboardFunc(void (GLUTCALLBACK *func)(unsigned
> char key, int x, int y));
> 
> SML Side:
> (*fun glutKeyboardFunc (kbd: char * int * int -> unit) = ( gKbdFA kbd;
> callGKbdF ())*)
> (* Special function callback *)
> val gSpecFA = _export "glutSpecialFuncArgument": int * int * int -> unit;
> val callGSpecF = _import "callGlutSpecialFunc": unit -> unit;
> =====================================================================
> 
> which generates a C header with pointer type warnings.

I can't reproduce the problem here.  Are you talking about the C
header generated by -export-header true?  Does that file have the
warnings or is it when compiling another file?  What are the pointer
type warnings?