From fb0811353f95769ff0d2b156d879320f4037e031 Mon Sep 17 00:00:00 2001
From: Sylvain <[EMAIL REDACTED]>
Date: Mon, 6 Mar 2023 10:42:44 +0100
Subject: [PATCH] Add IMG.h to fix static/extern protoype warnings
---
IMG.c | 17 ++---------------
IMG.h | 34 ++++++++++++++++++++++++++++++++++
IMG_ImageIO.m | 15 ++++++++-------
IMG_WIC.c | 17 +++++++++--------
IMG_avif.c | 9 +++++----
IMG_bmp.c | 1 +
IMG_gif.c | 1 +
IMG_jpg.c | 13 +++++++------
IMG_jxl.c | 9 +++++----
IMG_lbm.c | 1 +
IMG_pcx.c | 1 +
IMG_png.c | 14 +++++++-------
IMG_pnm.c | 1 +
IMG_qoi.c | 1 +
IMG_stb.c | 1 +
IMG_svg.c | 1 +
IMG_tga.c | 1 +
IMG_tif.c | 9 +++++----
IMG_webp.c | 9 +++++----
IMG_xcf.c | 1 +
IMG_xpm.c | 1 +
IMG_xv.c | 1 +
IMG_xxx.c | 5 +++++
23 files changed, 104 insertions(+), 59 deletions(-)
create mode 100644 IMG.h
diff --git a/IMG.c b/IMG.c
index a44ea9bb..bd811247 100644
--- a/IMG.c
+++ b/IMG.c
@@ -22,6 +22,7 @@
/* A simple library to load images of various formats as SDL surfaces */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
@@ -96,20 +97,6 @@ const SDL_version *IMG_Linked_Version(void)
return(&linked_version);
}
-extern int IMG_InitAVIF(void);
-extern void IMG_QuitAVIF(void);
-extern int IMG_InitJPG(void);
-extern void IMG_QuitJPG(void);
-extern int IMG_InitJXL(void);
-extern void IMG_QuitJXL(void);
-extern int IMG_InitPNG(void);
-extern void IMG_QuitPNG(void);
-extern int IMG_InitTIF(void);
-extern void IMG_QuitTIF(void);
-
-extern int IMG_InitWEBP(void);
-extern void IMG_QuitWEBP(void);
-
static int initialized = 0;
int IMG_Init(int flags)
@@ -151,7 +138,7 @@ int IMG_Init(int flags)
return initialized;
}
-void IMG_Quit()
+void IMG_Quit(void)
{
if (initialized & IMG_INIT_AVIF) {
IMG_QuitAVIF();
diff --git a/IMG.h b/IMG.h
new file mode 100644
index 00000000..c855d1e9
--- /dev/null
+++ b/IMG.h
@@ -0,0 +1,34 @@
+/*
+ SDL_image: An example image loading library for use with SDL
+ Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
+
+ This software is provided 'as-is', without any express or implied
+ warranty. In no event will the authors be held liable for any damages
+ arising from the use of this software.
+
+ Permission is granted to anyone to use this software for any purpose,
+ including commercial applications, and to alter it and redistribute it
+ freely, subject to the following restrictions:
+
+ 1. The origin of this software must not be misrepresented; you must not
+ claim that you wrote the original software. If you use this software
+ in a product, an acknowledgment in the product documentation would be
+ appreciated but is not required.
+ 2. Altered source versions must be plainly marked as such, and must not be
+ misrepresented as being the original software.
+ 3. This notice may not be removed or altered from any source distribution.
+*/
+
+extern int IMG_InitAVIF(void);
+extern void IMG_QuitAVIF(void);
+extern int IMG_InitJPG(void);
+extern void IMG_QuitJPG(void);
+extern int IMG_InitJXL(void);
+extern void IMG_QuitJXL(void);
+extern int IMG_InitPNG(void);
+extern void IMG_QuitPNG(void);
+extern int IMG_InitTIF(void);
+extern void IMG_QuitTIF(void);
+extern int IMG_InitWEBP(void);
+extern void IMG_QuitWEBP(void);
+
diff --git a/IMG_ImageIO.m b/IMG_ImageIO.m
index 1dde408d..3a7a2c0d 100644
--- a/IMG_ImageIO.m
+++ b/IMG_ImageIO.m
@@ -10,6 +10,7 @@
#if defined(__APPLE__) && !defined(SDL_IMAGE_USE_COMMON_BACKEND)
#include <SDL3/SDL_image.h>
+#include "IMG.h"
// Used because CGDataProviderCreate became deprecated in 10.5
#include <AvailabilityMacros.h>
@@ -188,7 +189,7 @@ static CFDictionaryRef CreateHintDictionary(CFStringRef uti_string_hint)
{
/* This code is adapted from Apple's Documentation found here:
* http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/index.html
- * Listing 9-4††Using a Quartz image as a texture source.
+ * Listing 9-4â â Using a Quartz image as a texture source.
* Unfortunately, this guide doesn't show what to do about
* non-RGBA image formats so I'm making the rest up.
* All this code should be scrutinized.
@@ -346,12 +347,12 @@ static CFDictionaryRef CreateHintDictionary(CFStringRef uti_string_hint)
#ifdef JPG_USES_IMAGEIO
-int IMG_InitJPG()
+int IMG_InitJPG(void)
{
return 0;
}
-void IMG_QuitJPG()
+void IMG_QuitJPG(void)
{
}
@@ -359,23 +360,23 @@ void IMG_QuitJPG()
#ifdef PNG_USES_IMAGEIO
-int IMG_InitPNG()
+int IMG_InitPNG(void)
{
return 0;
}
-void IMG_QuitPNG()
+void IMG_QuitPNG(void)
{
}
#endif /* PNG_USES_IMAGEIO */
-int IMG_InitTIF()
+int IMG_InitTIF(void)
{
return 0;
}
-void IMG_QuitTIF()
+void IMG_QuitTIF(void)
{
}
diff --git a/IMG_WIC.c b/IMG_WIC.c
index 14d53889..2e27258c 100644
--- a/IMG_WIC.c
+++ b/IMG_WIC.c
@@ -22,13 +22,14 @@
#if defined(SDL_IMAGE_USE_WIC_BACKEND)
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#define COBJMACROS
#include <initguid.h>
#include <wincodec.h>
static IWICImagingFactory* wicFactory = NULL;
-static int WIC_Init()
+static int WIC_Init(void)
{
if (wicFactory == NULL) {
HRESULT hr = CoCreateInstance(
@@ -46,39 +47,39 @@ static int WIC_Init()
return 0;
}
-static void WIC_Quit()
+static void WIC_Quit(void)
{
if (wicFactory) {
IWICImagingFactory_Release(wicFactory);
}
}
-int IMG_InitPNG()
+int IMG_InitPNG(void)
{
return WIC_Init();
}
-void IMG_QuitPNG()
+void IMG_QuitPNG(void)
{
WIC_Quit();
}
-int IMG_InitJPG()
+int IMG_InitJPG(void)
{
return WIC_Init();
}
-void IMG_QuitJPG()
+void IMG_QuitJPG(void)
{
WIC_Quit();
}
-int IMG_InitTIF()
+int IMG_InitTIF(void)
{
return WIC_Init();
}
-void IMG_QuitTIF()
+void IMG_QuitTIF(void)
{
WIC_Quit();
}
diff --git a/IMG_avif.c b/IMG_avif.c
index b7545044..4f51282b 100644
--- a/IMG_avif.c
+++ b/IMG_avif.c
@@ -22,6 +22,7 @@
/* This is a AVIF image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_AVIF
@@ -52,7 +53,7 @@ static struct {
if (lib.FUNC == NULL) { IMG_SetError("Missing avif.framework"); return -1; }
#endif
-int IMG_InitAVIF()
+int IMG_InitAVIF(void)
{
if ( lib.loaded == 0 ) {
#ifdef LOAD_AVIF_DYNAMIC
@@ -74,7 +75,7 @@ int IMG_InitAVIF()
return 0;
}
-void IMG_QuitAVIF()
+void IMG_QuitAVIF(void)
{
if ( lib.loaded == 0 ) {
return;
@@ -318,13 +319,13 @@ SDL_Surface *IMG_LoadAVIF_RW(SDL_RWops *src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitAVIF()
+int IMG_InitAVIF(void)
{
IMG_SetError("AVIF images are not supported");
return(-1);
}
-void IMG_QuitAVIF()
+void IMG_QuitAVIF(void)
{
}
diff --git a/IMG_bmp.c b/IMG_bmp.c
index 33a51a17..1ea35593 100644
--- a/IMG_bmp.c
+++ b/IMG_bmp.c
@@ -31,6 +31,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_BMP
diff --git a/IMG_gif.c b/IMG_gif.c
index ca67ec95..c4961769 100644
--- a/IMG_gif.c
+++ b/IMG_gif.c
@@ -22,6 +22,7 @@
/* This is a GIF image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_GIF
diff --git a/IMG_jpg.c b/IMG_jpg.c
index aed4c605..ebf55a5d 100644
--- a/IMG_jpg.c
+++ b/IMG_jpg.c
@@ -22,6 +22,7 @@
/* This is a JPEG image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#include <stdio.h>
#include <setjmp.h>
@@ -94,7 +95,7 @@ static struct {
lib.FUNC = FUNC;
#endif
-int IMG_InitJPG()
+int IMG_InitJPG(void)
{
if ( lib.loaded == 0 ) {
#ifdef LOAD_JPG_DYNAMIC
@@ -124,7 +125,7 @@ int IMG_InitJPG()
return 0;
}
-void IMG_QuitJPG()
+void IMG_QuitJPG(void)
{
if ( lib.loaded == 0 ) {
return;
@@ -548,13 +549,13 @@ static int IMG_SaveJPG_RW_jpeglib(SDL_Surface *surface, SDL_RWops *dst, int free
extern SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src);
-int IMG_InitJPG()
+int IMG_InitJPG(void)
{
/* Nothing to load */
return 0;
}
-void IMG_QuitJPG()
+void IMG_QuitJPG(void)
{
/* Nothing to unload */
}
@@ -640,13 +641,13 @@ SDL_Surface *IMG_LoadJPG_RW(SDL_RWops *src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitJPG()
+int IMG_InitJPG(void)
{
IMG_SetError("JPEG images are not supported");
return(-1);
}
-void IMG_QuitJPG()
+void IMG_QuitJPG(void)
{
}
diff --git a/IMG_jxl.c b/IMG_jxl.c
index 660d0fdf..2104f749 100644
--- a/IMG_jxl.c
+++ b/IMG_jxl.c
@@ -22,6 +22,7 @@
/* This is a JXL image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_JXL
@@ -51,7 +52,7 @@ static struct {
if (lib.FUNC == NULL) { IMG_SetError("Missing jxl.framework"); return -1; }
#endif
-int IMG_InitJXL()
+int IMG_InitJXL(void)
{
if ( lib.loaded == 0 ) {
#ifdef LOAD_JXL_DYNAMIC
@@ -73,7 +74,7 @@ int IMG_InitJXL()
return 0;
}
-void IMG_QuitJXL()
+void IMG_QuitJXL(void)
{
if ( lib.loaded == 0 ) {
return;
@@ -248,13 +249,13 @@ SDL_Surface *IMG_LoadJXL_RW(SDL_RWops *src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitJXL()
+int IMG_InitJXL(void)
{
IMG_SetError("JXL images are not supported");
return(-1);
}
-void IMG_QuitJXL()
+void IMG_QuitJXL(void)
{
}
diff --git a/IMG_lbm.c b/IMG_lbm.c
index 6763a5db..d1575118 100644
--- a/IMG_lbm.c
+++ b/IMG_lbm.c
@@ -32,6 +32,7 @@
#include <SDL3/SDL_endian.h>
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_LBM
diff --git a/IMG_pcx.c b/IMG_pcx.c
index 3081b1c6..1df8e395 100644
--- a/IMG_pcx.c
+++ b/IMG_pcx.c
@@ -36,6 +36,7 @@
#include <SDL3/SDL_endian.h>
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_PCX
diff --git a/IMG_png.c b/IMG_png.c
index 67539559..589fa523 100644
--- a/IMG_png.c
+++ b/IMG_png.c
@@ -22,6 +22,7 @@
/* This is a PNG image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
/* We'll have PNG save support by default */
#if !defined(SDL_IMAGE_SAVE_PNG)
@@ -137,7 +138,7 @@ static struct {
lib.FUNC = FUNC;
#endif
-int IMG_InitPNG()
+int IMG_InitPNG(void)
{
if ( lib.loaded == 0 ) {
#ifdef LOAD_PNG_DYNAMIC
@@ -186,7 +187,7 @@ int IMG_InitPNG()
return 0;
}
-void IMG_QuitPNG()
+void IMG_QuitPNG(void)
{
if ( lib.loaded == 0 ) {
return;
@@ -479,13 +480,13 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
extern SDL_Surface *IMG_LoadSTB_RW(SDL_RWops *src);
-int IMG_InitPNG()
+int IMG_InitPNG(void)
{
/* Nothing to load */
return 0;
}
-void IMG_QuitPNG()
+void IMG_QuitPNG(void)
{
/* Nothing to unload */
}
@@ -529,13 +530,13 @@ SDL_Surface *IMG_LoadPNG_RW(SDL_RWops *src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitPNG()
+int IMG_InitPNG(void)
{
IMG_SetError("PNG images are not supported");
return(-1);
}
-void IMG_QuitPNG()
+void IMG_QuitPNG(void)
{
}
@@ -708,7 +709,6 @@ static int IMG_SavePNG_RW_libpng(SDL_Surface *surface, SDL_RWops *dst, int freed
#define memcpy SDL_memcpy
#undef memset
#define memset SDL_memset
-#define strlen SDL_strlen
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
#define MINIZ_LITTLE_ENDIAN 1
#else
diff --git a/IMG_pnm.c b/IMG_pnm.c
index 19432415..62013c12 100644
--- a/IMG_pnm.c
+++ b/IMG_pnm.c
@@ -28,6 +28,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_PNM
diff --git a/IMG_qoi.c b/IMG_qoi.c
index 7d26f273..7b07dd6c 100644
--- a/IMG_qoi.c
+++ b/IMG_qoi.c
@@ -24,6 +24,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#include <limits.h> /* for INT_MAX */
#ifdef LOAD_QOI
diff --git a/IMG_stb.c b/IMG_stb.c
index 8b9d8411..d99607d1 100644
--- a/IMG_stb.c
+++ b/IMG_stb.c
@@ -20,6 +20,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef USE_STBIMAGE
diff --git a/IMG_svg.c b/IMG_svg.c
index 21febff8..c2cedc6d 100644
--- a/IMG_svg.c
+++ b/IMG_svg.c
@@ -24,6 +24,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_SVG
diff --git a/IMG_tga.c b/IMG_tga.c
index a94d66a2..2ec57ee9 100644
--- a/IMG_tga.c
+++ b/IMG_tga.c
@@ -26,6 +26,7 @@
#include <SDL3/SDL_endian.h>
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_TGA
diff --git a/IMG_tif.c b/IMG_tif.c
index 77b5e9a7..2ec2852c 100644
--- a/IMG_tif.c
+++ b/IMG_tif.c
@@ -24,6 +24,7 @@
/* This is a TIFF image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_TIF
@@ -48,7 +49,7 @@ static struct {
lib.FUNC = FUNC;
#endif
-int IMG_InitTIF()
+int IMG_InitTIF(void)
{
if ( lib.loaded == 0 ) {
#ifdef LOAD_TIF_DYNAMIC
@@ -67,7 +68,7 @@ int IMG_InitTIF()
return 0;
}
-void IMG_QuitTIF()
+void IMG_QuitTIF(void)
{
if ( lib.loaded == 0 ) {
return;
@@ -222,13 +223,13 @@ SDL_Surface* IMG_LoadTIF_RW(SDL_RWops* src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitTIF()
+int IMG_InitTIF(void)
{
IMG_SetError("TIFF images are not supported");
return(-1);
}
-void IMG_QuitTIF()
+void IMG_QuitTIF(void)
{
}
diff --git a/IMG_webp.c b/IMG_webp.c
index f0540633..cbab5937 100644
--- a/IMG_webp.c
+++ b/IMG_webp.c
@@ -22,6 +22,7 @@
/* This is a WEBP image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_WEBP
@@ -71,7 +72,7 @@ static struct {
if (lib.FUNC == NULL) { IMG_SetError("Missing webpdemux.framework"); return -1; }
#endif
-int IMG_InitWEBP()
+int IMG_InitWEBP(void)
{
if (lib.loaded == 0) {
#if defined(LOAD_WEBP_DYNAMIC) && defined(LOAD_WEBPDEMUX_DYNAMIC)
@@ -96,7 +97,7 @@ int IMG_InitWEBP()
return 0;
}
-void IMG_QuitWEBP()
+void IMG_QuitWEBP(void)
{
if (lib.loaded == 0) {
return;
@@ -373,13 +374,13 @@ IMG_Animation *IMG_LoadWEBPAnimation_RW(SDL_RWops *src)
#pragma warning(disable : 4100) /* warning C4100: 'op' : unreferenced formal parameter */
#endif
-int IMG_InitWEBP()
+int IMG_InitWEBP(void)
{
IMG_SetError("WEBP images are not supported");
return -1;
}
-void IMG_QuitWEBP()
+void IMG_QuitWEBP(void)
{
}
diff --git a/IMG_xcf.c b/IMG_xcf.c
index 4e32b4b5..bc7705f5 100644
--- a/IMG_xcf.c
+++ b/IMG_xcf.c
@@ -23,6 +23,7 @@
#include <SDL3/SDL_endian.h>
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_XCF
diff --git a/IMG_xpm.c b/IMG_xpm.c
index 7e88fde2..6703820e 100644
--- a/IMG_xpm.c
+++ b/IMG_xpm.c
@@ -46,6 +46,7 @@
*/
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_XPM
diff --git a/IMG_xv.c b/IMG_xv.c
index d5577576..724aeade 100644
--- a/IMG_xv.c
+++ b/IMG_xv.c
@@ -22,6 +22,7 @@
/* This is a XV thumbnail image file loading framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
#ifdef LOAD_XV
diff --git a/IMG_xxx.c b/IMG_xxx.c
index b51bec9f..f37136d6 100644
--- a/IMG_xxx.c
+++ b/IMG_xxx.c
@@ -22,6 +22,11 @@
/* This is a generic "format not supported" image framework */
#include <SDL3/SDL_image.h>
+#include "IMG.h"
+
+/* Declare 'extern' and move those function to IMG.h */
+static int IMG_isXXX(SDL_RWops *src);
+static SDL_Surface *IMG_LoadXXX_RW(SDL_RWops *src);
#ifdef LOAD_XXX