[gambit-list] Gambit on Windows with no console window

REPLeffect repleffect at gmail.com
Wed Apr 11 18:57:35 EDT 2012


On Wed, Apr 11, 2012 at 5:46 PM, REPLeffect <repleffect at gmail.com> wrote:
> On Tue, Apr 10, 2012 at 5:37 PM, Marc Feeley <feeley at 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).
>

  I just double-checked this by having the test program print out the
value of (current-output-port), changing this line:

     (println "test stdout:")

to this:

     (println "test stdout: " (current-output-port))

And the resulting output was this:

   test stdout: #<output-port #2 (stdout)>

(repeated 9 other times, of course).



More information about the Gambit-list mailing list