diff --git a/src/util/AttachToConsole.cpp b/src/util/AttachToConsole.cpp new file mode 100644 index 000000000..b1c993ad4 --- /dev/null +++ b/src/util/AttachToConsole.cpp @@ -0,0 +1,20 @@ +#include "AttachToConsole.hpp" + +#ifdef USEWINSDK +# include +#endif + +namespace chatterino { + +void attachToConsole() +{ +#ifdef USEWINSDK + if (AttachConsole(ATTACH_PARENT_PROCESS)) + { + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); + } +#endif +} + +} // namespace chatterino diff --git a/src/util/AttachToConsole.hpp b/src/util/AttachToConsole.hpp new file mode 100644 index 000000000..9fa8ba7b3 --- /dev/null +++ b/src/util/AttachToConsole.hpp @@ -0,0 +1,5 @@ +#pragma once + +namespace chatterino { +void attachToConsole(); +}