Re: [hatari-devel] Hatari debug mode

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


Hi,

On 17.8.2025 20.47, Christian Zietz wrote:
Eero Tamminen schrieb:

Was there some way to detect whether code is compiled as Windows console
program or GUI application, or do those builds need to use some define
to differentiate them?

AllocConsole fails for a console subsystem: "A process can be associated with only one console, so the AllocConsole function fails if the calling process already has a console."
https://learn.microsoft.com/en-us/windows/console/allocconsole

So that Windows GUI version would force the separate console window, but
in the Windows console version they would be no-ops (like is the case on
every other platform)?

But you don't have to change anything in Hatari (besides of course the gcc option from "-mwindows" to "-mconsole") to build a console version. The return value of AllocConsole is not checked anyway in Hatari's Win_OpenInternal. For a console version, AllocConsole silently fails and no *new* console window is opened. The existing console is used, as desired.

Shouldn't Hatari skip "freopen()" calls if allocConsole() fails (= returns zero)?

	- Eero

This is precisely what I always do with each of your releases: with a hex editor patch the subsystem indicator in the executable header from GUI to console. And nothing else.



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/