Add command-line option to show console output on Windows. (#632)

This commit is contained in:
Darío 2025-07-09 03:08:00 -03:00 committed by GitHub
parent af3ad296ea
commit 45af51ad37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -579,6 +579,22 @@ int main(int argc, char** argv) {
}
#ifdef _WIN32
for (int i = 1; i < argc; i++)
{
if (strcmp(argv[i], "--show-console") == 0)
{
if (GetConsoleWindow() == nullptr)
{
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stderr);
freopen("CONOUT$", "w", stdout);
}
break;
}
}
// Set up console output to accept UTF-8 on windows
SetConsoleOutputCP(CP_UTF8);