diff --git a/Include/Iony/Core/Console.h b/Include/Iony/Core/Console.h index 73d07d8..d52719b 100644 --- a/Include/Iony/Core/Console.h +++ b/Include/Iony/Core/Console.h @@ -24,6 +24,6 @@ #include "../Utils/Error.h" -IonyError iony_print(char *text, long length); +IonyError iony_print(const char *text, long length); #endif diff --git a/Src/Core/Console.c b/Src/Core/Console.c index fe469d7..a4b351e 100644 --- a/Src/Core/Console.c +++ b/Src/Core/Console.c @@ -27,14 +27,17 @@ #include "../../Include/Iony/Utils/System.h" #endif -IonyError iony_print(char *text, long length) { +IonyError iony_print(const char *text, const long length) { if (text == 0) { return IONY_ERROR_INVALID_POINTER; } #if defined(_WIN32) - static HANDLE standard_console_out_handle = GetStdHandle(STD_OUTPUT_HANDLE); - + static HANDLE standard_console_out_handle = 0; + if (standard_console_out_handle == 0) { + standard_console_out_handle = GetStdHandle(STD_OUTPUT_HANDLE); + } + DWORD characters_written; if (!WriteFile(standard_console_out_handle, text, length, &characters_written, 0)) { return IONY_ERROR_SYSTEM_CALL_FAILED;