Browse Source

Fix Windows build errors: config_parser.h, poll(), localtime()

- Replace sys/socket.h with platform_compat.h in config_parser.h
- Add #include <poll.h> for Windows in platform_compat.h
- Fix localtime() type mismatch: cast tv.tv_sec to time_t
- All 22 tests pass on Linux
nodeinfo-routing-update
Evgeny 2 months ago
parent
commit
1bd4bf5d11
  1. 3
      lib/debug_config.c
  2. 3
      lib/platform_compat.h
  3. 4
      src/config_parser.h

3
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);

3
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 <poll.h>
#else
// POSIX - include standard headers
#include <sys/time.h>

4
src/config_parser.h

@ -4,9 +4,7 @@
#include <stdint.h>
#include <stddef.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "../lib/platform_compat.h"
#ifdef __cplusplus
extern "C" {

Loading…
Cancel
Save