fix(console output): fixed windows console output handle initialization

This commit is contained in:
Mineplay 2025-10-17 15:18:02 -05:00
parent 39eb052853
commit c9ff202bc3
2 changed files with 7 additions and 4 deletions

View file

@ -24,6 +24,6 @@
#include "../Utils/Error.h" #include "../Utils/Error.h"
IonyError iony_print(char *text, long length); IonyError iony_print(const char *text, long length);
#endif #endif

View file

@ -27,13 +27,16 @@
#include "../../Include/Iony/Utils/System.h" #include "../../Include/Iony/Utils/System.h"
#endif #endif
IonyError iony_print(char *text, long length) { IonyError iony_print(const char *text, const long length) {
if (text == 0) { if (text == 0) {
return IONY_ERROR_INVALID_POINTER; return IONY_ERROR_INVALID_POINTER;
} }
#if defined(_WIN32) #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; DWORD characters_written;
if (!WriteFile(standard_console_out_handle, text, length, &characters_written, 0)) { if (!WriteFile(standard_console_out_handle, text, length, &characters_written, 0)) {