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"
IonyError iony_print(char *text, long length);
IonyError iony_print(const char *text, long length);
#endif

View file

@ -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;