From 5db9c0d5088df5ea130f4dfee9aae6e556126ed8 Mon Sep 17 00:00:00 2001 From: Jaeden Amero 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 53101cec..8767dda1 100644 --- a/src/debug/GdbStub.cpp +++ b/src/debug/GdbStub.cpp @@ -14,6 +14,7 @@ #ifndef _WIN32 #include +#include #include #include #include diff --git a/src/fatfs/ffsystem.c b/src/fatfs/ffsystem.c index ebde84a5..0efc6916 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 #include "ff.h"