From 89e3c652174cf1407c66f426ebbaf70c32b31c81 Mon Sep 17 00:00:00 2001
From: Ozkan Sezer <[EMAIL REDACTED]>
Date: Sat, 30 Nov 2024 06:03:10 +0300
Subject: [PATCH] silence -Wodr warning for unix builds using -flto:
dynapi/SDL_dynapi_procs.h:59:1: warning: 'SDL_RWFromFP_REAL' violates the C++ One Definition Rule [-Wodr]
59 | SDL_DYNAPI_PROC(SDL2_RWops*,SDL_RWFromFP,(void *a, SDL2_bool b),(a,b),return)
| ^
sdl2_compat.c:2493:1: note: 'SDL_RWFromFP_REAL' was previously declared here
2493 | SDL_RWFromFP(FILE *fp, SDL2_bool autoclose)
| ^
---
src/dynapi/SDL_dynapi_procs.h | 6 +-----
src/sdl2_compat.c | 4 ++--
src/sdl2_protos.h | 6 +-----
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 24523ee..1913738 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -53,11 +53,7 @@ SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *
SDL_DYNAPI_PROC(SDL_Thread*,SDL_CreateThread,(SDL_ThreadFunction a, const char *b, void *c),(a,b,c),return)
#endif
-#ifdef HAVE_STDIO_H
-SDL_DYNAPI_PROC(SDL2_RWops*,SDL_RWFromFP,(FILE *a, SDL2_bool b),(a,b),return)
-#else
-SDL_DYNAPI_PROC(SDL2_RWops*,SDL_RWFromFP,(void *a, SDL2_bool b),(a,b),return)
-#endif
+SDL_DYNAPI_PROC(SDL2_RWops*,SDL_RWFromFP,(void *a, SDL2_bool b),(a,b),return) /* FILE *a */
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
SDL_DYNAPI_PROC(int,SDL_RegisterApp,(const char *a, Uint32 b, void *c),(a,b,c),return)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index bcf8d22..0b24a55 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -2490,7 +2490,7 @@ stdio_close(SDL2_RWops *rwops2)
}
SDL_DECLSPEC SDL2_RWops * SDLCALL
-SDL_RWFromFP(FILE *fp, SDL2_bool autoclose)
+SDL_RWFromFP(void *fp, SDL2_bool autoclose)
{
SDL2_RWops *rwops = SDL_AllocRW();
if (rwops != NULL) {
@@ -2499,7 +2499,7 @@ SDL_RWFromFP(FILE *fp, SDL2_bool autoclose)
rwops->read = stdio_read;
rwops->write = stdio_write;
rwops->close = stdio_close;
- rwops->hidden.stdio.fp = fp;
+ rwops->hidden.stdio.fp = (FILE *) fp;
rwops->hidden.stdio.autoclose = autoclose;
rwops->type = SDL_RWOPS_STDFILE;
}
diff --git a/src/sdl2_protos.h b/src/sdl2_protos.h
index 8c5cff1..bbfc6d6 100644
--- a/src/sdl2_protos.h
+++ b/src/sdl2_protos.h
@@ -51,11 +51,7 @@ SDL2_PROTO(SDL_Thread*,CreateThread,(SDL_ThreadFunction a, const char *b, void *
SDL2_PROTO(SDL_Thread*,CreateThread,(SDL_ThreadFunction a, const char *b, void *c))
#endif
-#ifdef HAVE_STDIO_H
-SDL2_PROTO(SDL2_RWops*,RWFromFP,(FILE *a, SDL2_bool b))
-#else
-SDL2_PROTO(SDL2_RWops*,RWFromFP,(void *a, SDL2_bool b))
-#endif
+SDL2_PROTO(SDL2_RWops*,RWFromFP,(void *a, SDL2_bool b)) /* FILE *a */
#if defined(SDL_PLATFORM_WIN32) || defined(SDL_PLATFORM_GDK)
SDL2_PROTO(int,RegisterApp,(const char *a, Uint32 b, void *c))