Added Win32 AllocConsole

This commit is contained in:
Jack Andersen 2015-11-04 14:02:40 -10:00
parent 189e047977
commit 4c2442df2d
2 changed files with 21 additions and 0 deletions

View File

@ -98,6 +98,13 @@ void RegisterConsoleLogger();
*/ */
void RegisterFileLogger(const char* filepath); void RegisterFileLogger(const char* filepath);
#if _WIN32
/**
* @brief Spawn an application-owned cmd.exe window for displaying console output
*/
void CreateWin32Console();
#endif
#if LOG_UCS2 #if LOG_UCS2
/** /**

View File

@ -6,6 +6,8 @@
#define NOMINMAX #define NOMINMAX
#endif #endif
#include <windows.h> #include <windows.h>
#include <io.h>
#include <fcntl.h>
#else #else
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <fcntl.h> #include <fcntl.h>
@ -297,6 +299,18 @@ void RegisterConsoleLogger()
MainLoggers.emplace_back(new ConsoleLogger); MainLoggers.emplace_back(new ConsoleLogger);
} }
#if _WIN32
void CreateWin32Console()
{
/* Debug console */
AllocConsole();
freopen("CONIN$", "r", stdin);
freopen("CONOUT$", "w", stdout);
freopen("CONOUT$", "w", stderr);
}
#endif
struct FileLogger : public ILogger struct FileLogger : public ILogger
{ {
FILE* fp; FILE* fp;