Thread overview
Windows without console
Apr 13, 2008
boyd
Apr 13, 2008
Bill Baxter
Apr 13, 2008
boyd
April 13, 2008
Hi,

I've been working on a win32 program for D for a while now. Everything is working fine except that I can't get rid of the console that always pops up when the program starts.

I realised that I might have added some code that causes this, so I tested it out with the example at http://www.digitalmars.com/d/1.0/windows.html. Sadly enough I got the same results. I tried adding a .def file as recommended on that page, with no difference. I tried using DMD directly instead of dsss. Still the same.

Any ideas as to what could be wrong here?

Cheers,
Boyd
April 13, 2008
boyd wrote:
> Hi,
> 
> I've been working on a win32 program for D for a while now. Everything is working fine except that I can't get rid of the console that always pops up when the program starts.
> 
> I realised that I might have added some code that causes this, so I tested it out with the example at http://www.digitalmars.com/d/1.0/windows.html. Sadly enough I got the same results. I tried adding a .def file as recommended on that page, with no difference. I tried using DMD directly instead of dsss. Still the same.
> 
> Any ideas as to what could be wrong here?
> 
> Cheers,
> Boyd

I have this in my dsss.conf:

	version(gui) {
	  buildflags += -L/SUBSYSTEM:windows:5
	  buildflags += -gui
        } else {
	  buildflags += -L/SUBSYSTEM:console:5
        }


Build using -version=gui and it works for me.  No console created.  But then the standard library throws exceptions whenever you try to output something.  To fix that I have this inside main.d somewhere.

version(gui) {
    pragma(msg, "Compiling GUI Version");
    static this() {
        // redefine dout,derr,dlog to prevent IO exceptions
        version(Windows) {
            std.c.stdio.freopen("Nul", "w", dout.file);
            std.c.stdio.freopen("Nul", "w", derr.file);
        }
    }
}


--bb
April 13, 2008
That works. Thanks!

-------
On Sun, 13 Apr 2008 11:10:17 +0200, Bill Baxter <dnewsgroup@billbaxter.com> wrote:

> boyd wrote:
>> Hi,
>>  I've been working on a win32 program for D for a while now. Everything is working fine except that I can't get rid of the console that always pops up when the program starts.
>>  I realised that I might have added some code that causes this, so I tested it out with the example at http://www.digitalmars.com/d/1.0/windows.html. Sadly enough I got the same results. I tried adding a .def file as recommended on that page, with no difference. I tried using DMD directly instead of dsss. Still the same.
>>  Any ideas as to what could be wrong here?
>>  Cheers,
>> Boyd
>
> I have this in my dsss.conf:
>
> 	version(gui) {
> 	  buildflags += -L/SUBSYSTEM:windows:5
> 	  buildflags += -gui
>          } else {
> 	  buildflags += -L/SUBSYSTEM:console:5
>          }
>
>
> Build using -version=gui and it works for me.  No console created.  But then the standard library throws exceptions whenever you try to output something.  To fix that I have this inside main.d somewhere.
>
> version(gui) {
>      pragma(msg, "Compiling GUI Version");
>      static this() {
>          // redefine dout,derr,dlog to prevent IO exceptions
>          version(Windows) {
>              std.c.stdio.freopen("Nul", "w", dout.file);
>              std.c.stdio.freopen("Nul", "w", derr.file);
>          }
>      }
> }
>
>
> --bb