File melonds_PR2088.patch of Package melonds
From c4f719dbffa0d6119697cb8358b5d8623f4a5292 Mon Sep 17 00:00:00 2001
From: Jaeden Amero <jaeden@patater.com>
Date: Sun, 7 Jul 2024 14:26:52 +0000
Subject: [PATCH] Fix build for clang
Remove declaring _POSIX_SOURCE manually. Let the compiler take care of
this on its own, except on Windows where the compiler doesn't take care
of this. Additionally, include a missing header file for the definition
of struct sockaddr_in, which we need before we can allocate the struct.
With these fixes, we can build with Clang 18.1.5, although there are
many warnings.
---
src/debug/GdbStub.cpp | 1 +
src/fatfs/ffsystem.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/src/debug/GdbStub.cpp b/src/debug/GdbStub.cpp
index 53101cec28..8767dda1c0 100644
--- a/src/debug/GdbStub.cpp
+++ b/src/debug/GdbStub.cpp
@@ -14,6 +14,7 @@
#ifndef _WIN32
#include <sys/socket.h>
+#include <netinet/in.h>
#include <fcntl.h>
#include <poll.h>
#include <signal.h>
diff --git a/src/fatfs/ffsystem.c b/src/fatfs/ffsystem.c
index ebde84a50e..0efc6916e2 100644
--- a/src/fatfs/ffsystem.c
+++ b/src/fatfs/ffsystem.c
@@ -3,8 +3,13 @@
/* (C)ChaN, 2018 */
/*------------------------------------------------------------------------*/
+#ifdef _WIN32
+/* Windows will not define localtime_r for us unless we explicitly request it
+ * with macros. */
#define _POSIX_SOURCE
#define _POSIX_THREAD_SAFE_FUNCTIONS
+#endif
+
#include <time.h>
#include "ff.h"