From a58f3941130bda6c8d5e72a11f8250ff041d5ee3 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 6 Aug 2023 21:04:37 +0200
Subject: [PATCH] Fix -Wundef warnings
---
.github/workflows/main.yml | 3 ++-
src/dynapi/SDL_dynapi.c | 10 +++++-----
src/dynapi/SDL_dynapi_procs.h | 4 ++--
src/sdl2_compat.c | 2 +-
src/test/SDL_test_common.c | 4 ++--
test/checkkeys.c | 2 +-
test/checkkeysthreads.c | 2 +-
test/gles2funcs.h | 2 +-
test/loopwavequeue.c | 4 ++--
test/testaudiohotplug.c | 4 ++--
test/testautomation_keyboard.c | 4 ++--
test/testevdev.c | 2 +-
test/testgl2.c | 8 ++++----
test/testgles2.c | 8 ++++----
test/testgles2_sdf.c | 8 ++++----
15 files changed, 34 insertions(+), 33 deletions(-)
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 41cadda..17f3176 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -59,7 +59,8 @@ jobs:
sudo apt-get install -y libgl1-mesa-dev libglu1-mesa-dev
- name: Configure (CMake)
run: |
- cmake -B build -GNinja
+ cmake -B build -GNinja \
+ -DSDL2COMPAT_WERROR=ON
- name: Build (CMake)
run: |
cmake --build build/ --verbose
diff --git a/src/dynapi/SDL_dynapi.c b/src/dynapi/SDL_dynapi.c
index 72a56db..4f57a44 100644
--- a/src/dynapi/SDL_dynapi.c
+++ b/src/dynapi/SDL_dynapi.c
@@ -192,7 +192,7 @@ static SDL_DYNAPI_jump_table jump_table = {
SDL_InitDynamicAPI(); \
ret jump_table.fn args; \
}
-#define SDL_DYNAPI_PROC_NO_VARARGS 1
+#define SDL_DYNAPI_PROC_NO_VARARGS
#include "SDL_dynapi_procs.h"
#undef SDL_DYNAPI_PROC
#undef SDL_DYNAPI_PROC_NO_VARARGS
@@ -209,7 +209,7 @@ SDL_DYNAPI_VARARGS(static, _DEFAULT, SDL_InitDynamicAPI())
{ \
ret jump_table.fn args; \
}
-#define SDL_DYNAPI_PROC_NO_VARARGS 1
+#define SDL_DYNAPI_PROC_NO_VARARGS
#include "SDL_dynapi_procs.h"
#undef SDL_DYNAPI_PROC
#undef SDL_DYNAPI_PROC_NO_VARARGS
@@ -292,7 +292,7 @@ SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Error, ERROR)
SDL_DYNAPI_VARARGS_LOGFN_LOGSDLCALLS(Critical, CRITICAL)
#define SDL_DYNAPI_PROC(rc,fn,params,args,ret) \
rc SDLCALL fn##_LOGSDLCALLS params { SDL_Log_REAL("SDL2CALL %s", #fn); ret fn##_REAL args; }
-#define SDL_DYNAPI_PROC_NO_VARARGS 1
+#define SDL_DYNAPI_PROC_NO_VARARGS
#include "SDL_dynapi_procs.h"
#undef SDL_DYNAPI_PROC
#undef SDL_DYNAPI_PROC_NO_VARARGS
@@ -509,7 +509,7 @@ static void SDL_InitDynamicAPI(void)
/* SDL_AtomicLock calls SDL mutex functions to emulate if
SDL_ATOMIC_DISABLED, which we can't do here, so in such a
configuration, you're on your own. */
- #if !SDL_ATOMIC_DISABLED
+ #if !defined(SDL_ATOMIC_DISABLED)
static SDL_SpinLock lock = 0;
SDL_AtomicLock_REAL(&lock);
#endif
@@ -519,7 +519,7 @@ static void SDL_InitDynamicAPI(void)
already_initialized = SDL_TRUE;
}
- #if !SDL_ATOMIC_DISABLED
+ #if !defined(SDL_ATOMIC_DISABLED)
SDL_AtomicUnlock_REAL(&lock);
#endif
}
diff --git a/src/dynapi/SDL_dynapi_procs.h b/src/dynapi/SDL_dynapi_procs.h
index 1ab612c..17b4a83 100644
--- a/src/dynapi/SDL_dynapi_procs.h
+++ b/src/dynapi/SDL_dynapi_procs.h
@@ -30,7 +30,7 @@
*/
/* direct jump magic can use these, the rest needs special code. */
-#if !SDL_DYNAPI_PROC_NO_VARARGS
+#if !defined(SDL_DYNAPI_PROC_NO_VARARGS)
SDL_DYNAPI_PROC(int,SDL_SetError,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),return)
SDL_DYNAPI_PROC(void,SDL_Log,(SDL_PRINTF_FORMAT_STRING const char *a, ...),(a),)
SDL_DYNAPI_PROC(void,SDL_LogVerbose,(int a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),)
@@ -888,7 +888,7 @@ SDL_DYNAPI_PROC(void*,SDL_GetTextureUserData,(SDL_Texture *a),(a),return)
SDL_DYNAPI_PROC(int,SDL_RenderGeometry,(SDL_Renderer *a, SDL_Texture *b, const SDL_Vertex *c, int d, const int *e, int f),(a,b,c,d,e,f),return)
SDL_DYNAPI_PROC(int,SDL_RenderGeometryRaw,(SDL_Renderer *a, SDL_Texture *b, const float *c, int d, const SDL_Color *e, int f, const float *g, int h, int i, const void *j, int k, int l),(a,b,c,d,e,f,g,h,i,j,k,l),return)
SDL_DYNAPI_PROC(int,SDL_RenderSetVSync,(SDL_Renderer *a, int b),(a,b),return)
-#if !SDL_DYNAPI_PROC_NO_VARARGS
+#if !defined(SDL_DYNAPI_PROC_NO_VARARGS)
SDL_DYNAPI_PROC(int,SDL_asprintf,(char **a, SDL_PRINTF_FORMAT_STRING const char *b, ...),(a,b),return)
#endif
SDL_DYNAPI_PROC(int,SDL_vasprintf,(char **a, const char *b, va_list c),(a,b,c),return)
diff --git a/src/sdl2_compat.c b/src/sdl2_compat.c
index bb0b33a..488e59f 100644
--- a/src/sdl2_compat.c
+++ b/src/sdl2_compat.c
@@ -6261,7 +6261,7 @@ SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
return SDL_SetError("Destination rate is too high");
}
-#if DEBUG_CONVERT
+#ifdef DEBUG_CONVERT
SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);
#endif
diff --git a/src/test/SDL_test_common.c b/src/test/SDL_test_common.c
index 8781cc5..5636fd7 100644
--- a/src/test/SDL_test_common.c
+++ b/src/test/SDL_test_common.c
@@ -1120,7 +1120,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
SDL_DisplayMode mode;
int bpp;
Uint32 Rmask, Gmask, Bmask, Amask;
-#if SDL_VIDEO_DRIVER_WINDOWS
+#if defined(SDL_VIDEO_DRIVER_WINDOWS)
int adapterIndex = 0;
int outputIndex = 0;
#endif
@@ -1183,7 +1183,7 @@ SDL_bool SDLTest_CommonInit(SDLTest_CommonState *state)
}
}
-#if SDL_VIDEO_DRIVER_WINDOWS && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
+#if defined(SDL_VIDEO_DRIVER_WINDOWS) && !defined(__XBOXONE__) && !defined(__XBOXSERIES__)
/* Print the D3D9 adapter index */
adapterIndex = SDL_Direct3D9GetAdapterIndex(i);
SDL_Log("D3D9 Adapter Index: %d", adapterIndex);
diff --git a/test/checkkeys.c b/test/checkkeys.c
index 4efdc72..20ec8ef 100644
--- a/test/checkkeys.c
+++ b/test/checkkeys.c
@@ -284,7 +284,7 @@ int main(int argc, char *argv[])
textwin = SDLTest_TextWindowCreate(0, 0, 640, 480);
-#if __IPHONEOS__
+#ifdef __IPHONEOS__
/* Creating the context creates the view, which we need to show keyboard */
SDL_GL_CreateContext(window);
#endif
diff --git a/test/checkkeysthreads.c b/test/checkkeysthreads.c
index 3db5dd2..dd85754 100644
--- a/test/checkkeysthreads.c
+++ b/test/checkkeysthreads.c
@@ -266,7 +266,7 @@ int main(int argc, char *argv[])
renderer = SDL_CreateRenderer(window, -1, 0);
SDL_RenderPresent(renderer);
-#if __IPHONEOS__
+#ifdef __IPHONEOS__
/* Creating the context creates the view, which we need to show keyboard */
SDL_GL_CreateContext(window);
#endif
diff --git a/test/gles2funcs.h b/test/gles2funcs.h
index 4a90bce..82312ca 100644
--- a/test/gles2funcs.h
+++ b/test/gles2funcs.h
@@ -53,7 +53,7 @@ SDL_PROC(void, glPixelStorei, (GLenum, GLint))
SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid *))
SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
-#if __NACL__
+#ifdef __NACL__
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar **, const GLint *))
#else
SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const GLchar* const*, const GLint *))
diff --git a/test/loopwavequeue.c b/test/loopwavequeue.c
index 70dd072..17bdc24 100644
--- a/test/loopwavequeue.c
+++ b/test/loopwavequeue.c
@@ -21,7 +21,7 @@
#include "SDL.h"
-#if HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
@@ -97,7 +97,7 @@ int main(int argc, char *argv[])
wave.spec.callback = NULL; /* we'll push audio. */
-#if HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
/* Set the signals */
#ifdef SIGHUP
(void)signal(SIGHUP, poked);
diff --git a/test/testaudiohotplug.c b/test/testaudiohotplug.c
index e4bd9ac..1c4fba2 100644
--- a/test/testaudiohotplug.c
+++ b/test/testaudiohotplug.c
@@ -17,7 +17,7 @@
#include <stdio.h>
#include <stdlib.h>
-#if HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
quit(1);
}
-#if HAVE_SIGNAL_H
+#ifdef HAVE_SIGNAL_H
/* Set the signals */
#ifdef SIGHUP
(void)signal(SIGHUP, poked);
diff --git a/test/testautomation_keyboard.c b/test/testautomation_keyboard.c
index 0d459d0..153a4a0 100644
--- a/test/testautomation_keyboard.c
+++ b/test/testautomation_keyboard.c
@@ -464,7 +464,7 @@ int keyboard_setTextInputRect(void *arg)
int keyboard_setTextInputRectNegative(void *arg)
{
/* Some platforms set also an error message; prepare for checking it */
-#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
+#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
const char *expectedError = "Parameter 'rect' is invalid";
const char *error;
@@ -477,7 +477,7 @@ int keyboard_setTextInputRectNegative(void *arg)
SDLTest_AssertPass("Call to SDL_SetTextInputRect(NULL)");
/* Some platforms set also an error message; so check it */
-#if SDL_VIDEO_DRIVER_WINDOWS || SDL_VIDEO_DRIVER_ANDROID || SDL_VIDEO_DRIVER_COCOA
+#if defined(SDL_VIDEO_DRIVER_WINDOWS) || defined(SDL_VIDEO_DRIVER_ANDROID) || defined(SDL_VIDEO_DRIVER_COCOA)
error = SDL_GetError();
SDLTest_AssertPass("Call to SDL_GetError()");
SDLTest_AssertCheck(error != NULL, "Validate that error message was not NULL");
diff --git a/test/testevdev.c b/test/testevdev.c
index 919d591..50c13d1 100644
--- a/test/testevdev.c
+++ b/test/testevdev.c
@@ -20,7 +20,7 @@
static int run_test(void);
-#if HAVE_LIBUDEV_H || defined(SDL_JOYSTICK_LINUX)
+#if defined(HAVE_LIBUDEV_H) || defined(SDL_JOYSTICK_LINUX)
#include <stdint.h>
diff --git a/test/testgl2.c b/test/testgl2.c
index 145ab87..78a91a2 100644
--- a/test/testgl2.c
+++ b/test/testgl2.c
@@ -45,15 +45,15 @@ static GL_Context ctx;
static int LoadContext(GL_Context *data)
{
-#if SDL_VIDEO_DRIVER_UIKIT
+#if defined(SDL_VIDEO_DRIVER_UIKIT)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_ANDROID
+#elif defined(SDL_VIDEO_DRIVER_ANDROID)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_PANDORA
+#elif defined(SDL_VIDEO_DRIVER_PANDORA)
#define __SDL_NOGETPROCADDR__
#endif
-#if defined __SDL_NOGETPROCADDR__
+#if defined(__SDL_NOGETPROCADDR__)
#define SDL_PROC(ret, func, params) data->func = func;
#else
#define SDL_PROC(ret, func, params) \
diff --git a/test/testgles2.c b/test/testgles2.c
index a80b006..2e3ffaa 100644
--- a/test/testgles2.c
+++ b/test/testgles2.c
@@ -69,15 +69,15 @@ static GLES2_Context ctx;
static int LoadContext(GLES2_Context *data)
{
-#if SDL_VIDEO_DRIVER_UIKIT
+#if defined(SDL_VIDEO_DRIVER_UIKIT)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_ANDROID
+#elif defined(SDL_VIDEO_DRIVER_ANDROID)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_PANDORA
+#elif defined(SDL_VIDEO_DRIVER_PANDORA)
#define __SDL_NOGETPROCADDR__
#endif
-#if defined __SDL_NOGETPROCADDR__
+#if defined(__SDL_NOGETPROCADDR__)
#define SDL_PROC(ret, func, params) data->func = func;
#else
#define SDL_PROC(ret, func, params) \
diff --git a/test/testgles2_sdf.c b/test/testgles2_sdf.c
index cbb97fa..43f9c82 100644
--- a/test/testgles2_sdf.c
+++ b/test/testgles2_sdf.c
@@ -68,15 +68,15 @@ static GLES2_Context ctx;
static int LoadContext(GLES2_Context *data)
{
-#if SDL_VIDEO_DRIVER_UIKIT
+#if defined(SDL_VIDEO_DRIVER_UIKIT)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_ANDROID
+#elif defined(SDL_VIDEO_DRIVER_ANDROID)
#define __SDL_NOGETPROCADDR__
-#elif SDL_VIDEO_DRIVER_PANDORA
+#elif defined(SDL_VIDEO_DRIVER_PANDORA)
#define __SDL_NOGETPROCADDR__
#endif
-#if defined __SDL_NOGETPROCADDR__
+#if defined(__SDL_NOGETPROCADDR__)
#define SDL_PROC(ret, func, params) data->func = func;
#else
#define SDL_PROC(ret, func, params) \