Problem with win32 GUI application using console
Thu Nov 22 02:28:00 GMT 2007
I'm building a native Win32 GUI application which should be able to
display a console on demand for debugging purposes. I found that my
program was crashing when compiled with Cygwin, however it worked fine
with Visual Studio.
Here is the output of gcc --version:
gcc (GCC) 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I narrowed the problem down to a short test case. Here goes:
/* Compile with -mno-cygwin -mwindows */
int APIENTRY WinMain(HINSTANCE hInstance,
HANDLE h = GetStdHandle((intptr_t)STD_OUTPUT_HANDLE);
if(h == INVALID_HANDLE_VALUE)
int fd = _open_osfhandle(h,_O_TEXT);
if(fd == -1)
FILE *fp = _fdopen(fd,"w");
Let me know if you need any additional information.
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
More information about the Cygwin