[MLton-user] Linking issues with FFI on Vista

Wesley W. Terpstra wesley at terpstra.ca
Mon Sep 8 05:59:54 PDT 2008


On Mon, Sep 8, 2008 at 2:29 PM, John Reppy <t-johrep at microsoft.com> wrote:

> I have the following SML code for handling the display callback in GLUT:
>
>    val exportDisplay           = _export "glutDisplayCB" stdcall : (unit ->
> unit) -> unit;
>    val glutDisplayCB           = _address "glutDisplayCB" : Ptr.t;


In newer versions of MLton (like svn/HEAD), that code is in error. The
_export has an implied symbol scope of "public", but the _address as you've
use it has an implied symbol scope of "external". Because it's external it
is trying to import the _address from a DLL. The code it generated is
correct for this purpose. What you need to do is this:

_export "glutDisplayCB" private : (unit -> unit) -> unit;
_address "glutDisplayCB" private : Ptr.t;

This makes the symbol scope agree in both cases as being private. You could
also use public, if you liked. I don't know if you need 'stdcall' or not.
Check the OpenGL docs. If you do, it will probably segfault when it tries to
run the callback. ;-)

Unfortunately, symbol scopes are not yet documented. They've only recently
been implemented. Except for the case of taking the address of an exported
function, though, it shouldn't be necessary to know how it works.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mlton.org/pipermail/mlton-user/attachments/20080908/81e08415/attachment.html


More information about the MLton-user mailing list