RE: writing to stdout in an windows app without a console

On 16 February 2005 14:06, Duncan Coutts wrote:
On Wed, 2005-02-16 at 14:31 +0200, Krasimir Angelov wrote:
On Wed, 16 Feb 2005 12:01:06 +0000, Duncan Coutts
wrote: What's your opinion of making writing to stdout fail without raising an exception when the application is compiled with --subsystem windows?
I think the current behaviour is the right one. After all we don't have valid stdout/stdin and I don't see any reason to hide this.
True, but it's not the behaviour that other windows programming systems implement:
For example MS's C library happily ignores output to stdout:
#include
int main () { int res_code = fprintf(stdout, "hello world!\n"); fprintf(stderr, "res_code = %d\n", res_code);
return 0; }
now compiling with mingw's gcc: gcc testio.c -Xlinker --subsystem -Xlinker windows
and from a windows console (ie not a msys / cygwin window)
a.exe 2> err
then saying "type err" gives us the output: res_code = 13
I've seen this behaviour vary between versions of Windows (maybe even between versions of msvcrt, MS's C library). A strange experience we had with the Visual Studio extension was that I was initially just doing output to stderr from the DLL for debugging, which worked fine on my machine but crashed on other people's machines. We had to remove all uses of stdout/stderr from the Haskell DLL (including the runtime!) to get it going reliably. Cheers, Simon

On Wed, 2005-02-16 at 14:49 +0000, Simon Marlow wrote:
On 16 February 2005 14:06, Duncan Coutts wrote:
On Wed, 2005-02-16 at 14:31 +0200, Krasimir Angelov wrote:
On Wed, 16 Feb 2005 12:01:06 +0000, Duncan Coutts
wrote: What's your opinion of making writing to stdout fail without raising an exception when the application is compiled with --subsystem windows?
I've seen this behaviour vary between versions of Windows (maybe even between versions of msvcrt, MS's C library). A strange experience we had with the Visual Studio extension was that I was initially just doing output to stderr from the DLL for debugging, which worked fine on my machine but crashed on other people's machines. We had to remove all uses of stdout/stderr from the Haskell DLL (including the runtime!) to get it going reliably.
Ok, fair enough. It sounds like with the improvements in ghc 6.4 we'll be able to turn the --subsystem windows on by default for gtk2hs when using ghc 6.4, though we'll still have to warn people not to use normal output functions. [and we'll have to fix all our demos! :-) ] Duncan
participants (2)
-
Duncan Coutts
-
Simon Marlow