diff --git a/src/xenia/base/cvar.cc b/src/xenia/base/cvar.cc index 2f48c6c46..cd85c7a68 100644 --- a/src/xenia/base/cvar.cc +++ b/src/xenia/base/cvar.cc @@ -65,6 +65,7 @@ void ParseLaunchArguments(int& argc, char**& argv, auto result = options.parse(argc, argv); if (result.count("help")) { + xe::AttachConsole(); if (xe::has_console_attached()) { PrintHelpAndExit(); } else { @@ -88,6 +89,7 @@ void ParseLaunchArguments(int& argc, char**& argv, } } } catch (const cxxopts::OptionException& e) { + xe::AttachConsole(); if (xe::has_console_attached()) { std::cout << e.what() << std::endl; PrintHelpAndExit(); diff --git a/src/xenia/base/main.h b/src/xenia/base/main.h index 792fee5d6..324abfe71 100644 --- a/src/xenia/base/main.h +++ b/src/xenia/base/main.h @@ -22,6 +22,8 @@ namespace xe { // Returns true if there is a user-visible console attached to receive stdout. bool has_console_attached(); +void AttachConsole(); + // Extern defined by user code. This must be present for the application to // launch. struct EntryInfo { diff --git a/src/xenia/base/main_posix.cc b/src/xenia/base/main_posix.cc index 1e5e9e526..8d14f9219 100644 --- a/src/xenia/base/main_posix.cc +++ b/src/xenia/base/main_posix.cc @@ -18,6 +18,8 @@ namespace xe { bool has_console_attached() { return true; } +void AttachConsole() {} + } // namespace xe extern "C" int main(int argc, char** argv) { diff --git a/src/xenia/base/main_win.cc b/src/xenia/base/main_win.cc index 6cf80b7ae..6cbf8c9ae 100644 --- a/src/xenia/base/main_win.cc +++ b/src/xenia/base/main_win.cc @@ -50,10 +50,6 @@ bool has_shell_environment_variable() { } void AttachConsole() { - if (!cvars::enable_console) { - return; - } - bool has_console = ::AttachConsole(ATTACH_PARENT_PROCESS) == TRUE; if (!has_console || !has_shell_environment_variable()) { // We weren't launched from a console, so just return. @@ -145,7 +141,9 @@ int Main() { // Attach a console so we can write output to stdout. If the user hasn't // redirected output themselves it'll pop up a window. - xe::AttachConsole(); + if (cvars::enable_console) { + xe::AttachConsole(); + } // Setup COM on the main thread. // NOTE: this may fail if COM has already been initialized - that's OK.