[MLton-user] Linking (?) 'print' means I can only run from the mingw command line

Matthew Fluet fluet at tti-c.org
Mon Sep 15 10:36:06 PDT 2008


On Sun, 14 Sep 2008, Tom 7 wrote:
> I'm trying to debug a problem with using mlton+mingw+SDL on windows. 
> Everything works fine when I run my app from the mingw command line, but when 
> I run it from the DOS prompt or by clicking it in explorer, it terminates 
> immediately and silently. I spent some time whittling it down and it happens 
> even when I'm not using SDL.
>
> The only difference is 
> the mention of the 'print' function in dead code. My guess is that this 
> causes some I/O part of the Basis to be included (But then not eliminated?), 
> which creates some more initialization steps (binding to stdout, perhaps) 
> that abort the program when run in the click environment rather than the 
> mingw command line environment.
>
> Does this sound plausible? If so, what code should I look at? Or is there 
> some simple fix? =)

>From the comments of Wesley, it does seem as though demanding the 
initialization of TextIO is resulting in an uncaught exception, which 
would normally be acknowledged via a message to stderr, but that 
apparently doesn't exist.

You might be able to make progress with your application as a whole using:

Index: basis-library/posix/io.sml
===================================================================
--- basis-library/posix/io.sml	(revision 6853)
+++ basis-library/posix/io.sml	(working copy)
@@ -182,7 +182,7 @@
   *)
  local
     val pos0 = Position.fromInt 0
-   fun isReg fd = FS.ST.isReg(FS.fstat fd)
+   fun isReg fd = FS.ST.isReg(FS.fstat fd) handle _ => false
     fun posFns (closed, fd) =
        if (isReg fd)
           then let



More information about the MLton-user mailing list