Skip to content

Commit

Permalink
Custom Console linux compilation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmanek94 committed Sep 17, 2023
1 parent eb6b909 commit 42bb449
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Source/Client/CustomConsole.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

#include <Tracer.hxx>

#ifdef _WIN32
#include <Windows.h>
#include <io.h>
#include <fcntl.h>
#endif

#include <fstream>
#include <iostream>
Expand All @@ -17,10 +19,12 @@ namespace universelan::client {
{
tracer::Trace trace{ };

#ifdef _WIN32
FILE* fDummy;
freopen_s(&fDummy, "CONIN$", "r", stdin);
freopen_s(&fDummy, "CONOUT$", "w", stderr);
freopen_s(&fDummy, "CONOUT$", "w", stdout);
#endif

//Clear the error state for each of the C++ standard stream objects. We need to do this, as
//attempts to access the standard streams before they refer to a valid target will cause the
Expand Down Expand Up @@ -48,6 +52,7 @@ namespace universelan::client {

CustomConsoleEnabled = true;

#ifdef _WIN32
// allocate a console for this app
AllocConsole();

Expand All @@ -57,5 +62,6 @@ namespace universelan::client {
BindStdHandlesToConsole();

SetConsoleTitleA("UniverseLAN");
#endif
}
}

0 comments on commit 42bb449

Please sign in to comment.