From 1bd4bf5d1140c4d60dee5f30029d7fc4bd83db6d Mon Sep 17 00:00:00 2001 From: Evgeny Date: Sun, 15 Feb 2026 02:56:08 +0300 Subject: [PATCH] Fix Windows build errors: config_parser.h, poll(), localtime() - Replace sys/socket.h with platform_compat.h in config_parser.h - Add #include for Windows in platform_compat.h - Fix localtime() type mismatch: cast tv.tv_sec to time_t - All 22 tests pass on Linux --- lib/debug_config.c | 3 ++- lib/platform_compat.h | 3 +++ src/config_parser.h | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/debug_config.c b/lib/debug_config.c index 2f058be..5521d15 100644 --- a/lib/debug_config.c +++ b/lib/debug_config.c @@ -217,7 +217,8 @@ void debug_output(debug_level_t level, debug_category_t category, /* Add timestamp with microseconds: hh:mm:ss-xxx.yyy */ struct timeval tv; gettimeofday(&tv, NULL); - struct tm* tm_info = localtime(&tv.tv_sec); + time_t tv_sec = (time_t)tv.tv_sec; + struct tm* tm_info = localtime(&tv_sec); char time_str[32]; strftime(time_str, sizeof(time_str), "%H:%M:%S", tm_info); offset += snprintf(buffer + offset, remaining, "[%s-%03ld.%03ld] ", time_str, tv.tv_usec / 1000, tv.tv_usec % 1000); diff --git a/lib/platform_compat.h b/lib/platform_compat.h index bef3b4e..6a82d08 100644 --- a/lib/platform_compat.h +++ b/lib/platform_compat.h @@ -103,6 +103,9 @@ // nanosleep already defined in pthread_time.h on MSYS2 + // poll is in ws2tcpip.h or poll.h on MSYS2 + #include + #else // POSIX - include standard headers #include diff --git a/src/config_parser.h b/src/config_parser.h index 15a99c5..fa5d9c4 100644 --- a/src/config_parser.h +++ b/src/config_parser.h @@ -4,9 +4,7 @@ #include #include -#include -#include -#include +#include "../lib/platform_compat.h" #ifdef __cplusplus extern "C" {