send console output to parent process's console.

this way Windows release builds can get console output if run from cmd.exe, just like under Linux
This commit is contained in:
StapleButter 2018-12-12 15:18:43 +01:00
parent affe1c084f
commit 24d6bd2786
1 changed files with 9 additions and 0 deletions

View File

@ -1666,8 +1666,17 @@ int CALLBACK WinMain(HINSTANCE hinst, HINSTANCE hprev, LPSTR cmdline, int cmdsho
if (res != len) { delete[] argv[i]; argv[i] = nullarg; }
}
if (AttachConsole(ATTACH_PARENT_PROCESS))
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
printf("\n");
}
int ret = main(argc, argv);
printf("\n\n>");
for (int i = 0; i < argc; i++) if (argv[i] != nullarg) delete[] argv[i];
delete[] argv;