WX: Redirect stdout to console output

Thank Windows for its default console handling.

This fixes std::cout not working on Windows.
This commit is contained in:
Léo Lam 2017-03-22 13:32:24 +01:00
parent 77b389bf99
commit c1cd7d9c0e
1 changed files with 10 additions and 0 deletions

View File

@ -107,6 +107,16 @@ bool DolphinApp::OnInit()
wxHandleFatalExceptions(true);
#endif
#ifdef _WIN32
const bool console_attached = AttachConsole(ATTACH_PARENT_PROCESS) != FALSE;
HANDLE stdout_handle = ::GetStdHandle(STD_OUTPUT_HANDLE);
if (console_attached && stdout_handle)
{
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif
ParseCommandLine();
std::lock_guard<std::mutex> lk(s_init_mutex);