On Wed, 2005-06-22 at 12:02 +0200, ROUGE Alain wrote:
> a stupid question ---> when I click on a compiled demo, the terminal is
> launched in background. Is there a way to avoid this?
Yes, by default the terminal is launched. It is possible to avoid this
but if you do this you need to be careful *never* to use the standard
input/output/error or the program will exit with an exception.
So that means never using putStr, print, getContents etc. If you do
you'll get an exception about hPutChar findign that there is no valid
file descriptor. This is because the input/output/error for gui programs
is not connected.
The way to do it is to pass a special option to the linker:
ghc --make Foo.hs -optl-mwindows
So the reason we have not done this for the demos that come with Gtk2Hs
on windows is that many of them do write status messages to the console
and so would fail if we did not show the console window.
If we could somehow improve this behaviour so it wasn't so poor we could
make the -optl-mwindows the default. But at the moment it would cause
far too many questions about mysteriously failing programs. Better
behaviour might be to create the console as soon as stdin/stdout/stderr
is used but we;d have to persuade the GHC devs.