[hatari-devel] Console I/O on Windows

Vincent Rivière vincent.riviere at freesbee.fr
Tue Jan 4 21:39:02 CET 2011


Nicolas Pomarède wrote:
> According to gcc, -mconsole is the default when not specified and tells to
> build a console application.
> -mwindows should be used to build a GUI application (it's not used here).

True.

Furthermore, the gcc option "-mconsole" is translated to "--subsystem 
console" on the linker command line.

> Vincent, could you tell me what bytes you changed (using an hex editor I
> guess) to modify the behaviour of the exe ? I will try to adapt the flags to
> get the same header.

Byte offset 0xdc
02: Windowed
03: Console

The reference documentation is here:
http://msdn.microsoft.com/en-us/library/ms680339(v=vs.85).aspx
See the Subsystem member.

And... many apologies.
My hack tool toggled the subsystem, and I didn't notice it was the opposite 
of what I thinked :-[

As Nicolas said, the current Hatari is compiled with an implicit -mconsole 
option. The subsystem is 03. And the console I/O does not work.

But if you change the subsystem to 02 (or compile with -mwindows) everything 
work fine :-)
If you double-click hatari.exe, there is no ugly console opened by default.
If you make a shortcut to "hatari.exe -D", you get a console, debug output, 
and the debugger.

Finally, the solution seems to be very simple.
SDL really does black magic with stdio.

Beware, if you close the console window, Hatari crashes. But this is another 
story.

-- 
Vincent Rivière



More information about the hatari-devel mailing list