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

Tom 7 twm at andrew.cmu.edu
Wed Sep 17 18:21:44 PDT 2008


This works, thanks guys! I also have to be careful not to print anything 
out while the program runs, but that can be arranged.

I need -mwindows in order to run my program with SDL, yes.

For my purposes, the ideal behavior would be for writes to stdout and
stderr to be discarded when running without a console. Being able to pop
up a window with output would be great for debugging time, but when being
run by users I wouldn't want them to see that stuff. This is what happens
on OS X without doing anything special. But if the behavior engendered by 
the patch below were the default, that would be fine too.

  Tom

> 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
>
>


[ NEW! : http://tom7.org/       ]
[ OLD! : http://fonts.tom7.com/ ]



More information about the MLton-user mailing list