On Tue, Apr 10, 2012 at 5:37 PM, Marc Feeley feeley@iro.umontreal.ca wrote:
On 2012-04-10, at 3:13 PM, REPLeffect wrote:
I had already been running my app with -:d-, but somehow missed -:d0 -- that almost gives me what I want (by suppressing the error messages). However, I have some messages in my app that are being sent to stdout, and even with -:d0, the console is still being shown by these. Of course, the AllocConsole call is the culprit.
Can you explain this a bit more. I don't understand why the output would go to the console if you write to stdout. Can you verify that this is the case? Note that the pp procedure defaults to writing to the REPL port.
I am actually using println (not pp) in the messages that are causing the console to open.
I was able to reproduce the problem by modifying Mikael's MessageBox example. This version opens the message box, then once the message box is closed, it prints to stdout once each second for 10 seconds:
(c-declare "#include <windows.h>") (define message-box (c-lambda (UTF-8-string) void "MessageBox(0,___arg1,"Dbg",0);")) (message-box "Hi!") (let loop ((count 0)) (println "test stdout") (thread-sleep! 1) (if (< count 10) (loop (+ count 1))))
I saved that as test.scm, and compiled it under MinGW like this:
gsc -link test.scm
g++ -c -I"C:/Gambit-C/include" -I"C:/Gambit-C/lib" -D___SINGLE_HOST -D_WINDOWS test_.c test.c
g++ -mthreads -Wl,-subsystem,windows -o test.exe test.o test_.o -LC:/Gambit-C/lib -lgambc -L. -lkernel32 -luser32 -lgdi32 -lmingw32 -lws2_32
When I run test.exe, the message box appears, then I click 'OK' and the console appears, displaying the line "test stdout" 10 times (once per second).
Note that if you want to ignore all output sent to the current-output-port, you could simply do this:
(current-output-port (open-dummy))
^^ That actually works beautifully. open-dummy could come in very handy. Thanks! If I can't figure out a better solution, that's what I'll do.
Let me know if you want me to test anything further.