SDL: Use #ifdef/#ifndef instead of #if defined/#if \!defined

From b6ae281e97c4e4680a9010e7e13fe1222c0bcd4b Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 30 Mar 2023 20:26:31 +0200
Subject: [PATCH] Use #ifdef/#ifndef instead of #if defined/#if \!defined

---
 cmake/test/main_lib.c                       |  2 +-
 include/SDL3/SDL_assert.h                   |  4 +-
 include/SDL3/SDL_begin_code.h               | 10 +--
 include/SDL3/SDL_intrin.h                   |  8 +-
 include/SDL3/SDL_main.h                     |  4 +-
 include/SDL3/SDL_main_impl.h                |  2 +-
 include/SDL3/SDL_opengl.h                   |  2 +-
 include/SDL3/SDL_platform_defines.h         | 26 +++----
 include/SDL3/SDL_rwops.h                    |  2 +-
 include/SDL3/SDL_stdinc.h                   |  8 +-
 include/SDL3/SDL_system.h                   |  2 +-
 include/SDL3/SDL_syswm.h                    | 24 +++---
 include/SDL3/SDL_test_common.h              |  2 +-
 src/SDL.c                                   |  8 +-
 src/SDL_assert.c                            |  8 +-
 src/SDL_internal.h                          |  8 +-
 src/SDL_log.c                               |  2 +-
 src/atomic/SDL_atomic.c                     | 10 +--
 src/atomic/SDL_spinlock.c                   |  6 +-
 src/audio/SDL_audio.c                       |  4 +-
 src/audio/SDL_audiocvt.c                    |  8 +-
 src/audio/SDL_audiotypecvt.c                |  4 +-
 src/audio/coreaudio/SDL_coreaudio.h         |  2 +-
 src/audio/coreaudio/SDL_coreaudio.m         |  2 +-
 src/audio/directsound/SDL_directsound.c     |  8 +-
 src/audio/netbsd/SDL_netbsdaudio.c          |  2 +-
 src/core/haiku/SDL_BeApp.cc                 |  2 +-
 src/core/linux/SDL_fcitx.c                  |  2 +-
 src/core/openbsd/SDL_wscons_kbd.c           |  2 +-
 src/core/windows/SDL_windows.c              |  4 +-
 src/core/windows/SDL_windows.h              |  6 +-
 src/cpuinfo/SDL_cpuinfo.c                   | 30 +++----
 src/dynapi/SDL_dynapi.c                     |  2 +-
 src/dynapi/SDL_dynapi_procs.h               |  2 +-
 src/events/SDL_mouse.c                      |  4 +-
 src/events/SDL_mouse_c.h                    |  2 +-
 src/events/SDL_touch.c                      |  2 +-
 src/file/SDL_rwops.c                        |  2 +-
 src/filesystem/ps2/SDL_sysfilesystem.c      |  2 +-
 src/filesystem/psp/SDL_sysfilesystem.c      |  2 +-
 src/filesystem/unix/SDL_sysfilesystem.c     | 10 +--
 src/hidapi/SDL_hidapi.c                     | 38 ++++-----
 src/hidapi/android/hid.h                    |  4 +-
 src/hidapi/libusb/hid.c                     |  4 +-
 src/hidapi/mac/hid.c                        |  2 +-
 src/hidapi/windows/hid.c                    |  4 +-
 src/joystick/SDL_gamepad.c                  | 14 ++--
 src/joystick/SDL_gamepad_db.h               |  6 +-
 src/joystick/SDL_joystick.c                 | 16 ++--
 src/joystick/apple/SDL_mfijoystick.m        |  4 +-
 src/joystick/bsd/SDL_bsdjoystick.c          |  4 +-
 src/joystick/darwin/SDL_iokitjoystick.c     |  2 +-
 src/joystick/hidapi/SDL_hidapi_luna.c       |  2 +-
 src/joystick/hidapi/SDL_hidapi_ps3.c        |  2 +-
 src/joystick/hidapi/SDL_hidapi_steam.c      |  2 +-
 src/joystick/hidapi/SDL_hidapi_wii.c        |  2 +-
 src/joystick/hidapi/SDL_hidapi_xbox360.c    |  2 +-
 src/joystick/hidapi/SDL_hidapijoystick.c    |  2 +-
 src/joystick/linux/SDL_sysjoystick.c        |  2 +-
 src/joystick/virtual/SDL_virtualjoystick.c  |  2 +-
 src/joystick/windows/SDL_rawinputjoystick.c |  2 +-
 src/joystick/windows/SDL_windowsjoystick.c  |  2 +-
 src/misc/unix/SDL_sysurl.c                  |  2 +-
 src/render/SDL_render.c                     | 16 ++--
 src/render/direct3d11/SDL_render_d3d11.c    |  4 +-
 src/render/direct3d11/SDL_shaders_d3d11.c   | 24 +++---
 src/render/opengles2/SDL_render_gles2.c     |  2 +-
 src/sensor/vita/SDL_vitasensor.c            |  4 +-
 src/sensor/windows/SDL_windowssensor.c      |  2 +-
 src/stdlib/SDL_getenv.c                     |  8 +-
 src/stdlib/SDL_mslibc.c                     |  8 +-
 src/stdlib/SDL_qsort.c                      |  4 +-
 src/stdlib/SDL_stdlib.c                     | 86 ++++++++++-----------
 src/stdlib/SDL_string.c                     | 60 +++++++-------
 src/stdlib/SDL_vacopy.h                     |  2 +-
 src/test/SDL_test_harness.c                 |  2 +-
 src/thread/SDL_thread.c                     |  2 +-
 src/thread/SDL_thread_c.h                   |  2 +-
 src/thread/generic/SDL_syscond.c            |  2 +-
 src/thread/generic/SDL_sysmutex.c           |  6 +-
 src/thread/generic/SDL_syssem.c             |  2 +-
 src/thread/psp/SDL_sysmutex.c               |  6 +-
 src/thread/pthread/SDL_sysmutex.c           |  2 +-
 src/thread/pthread/SDL_systhread.c          |  4 +-
 src/thread/vita/SDL_sysmutex.c              |  6 +-
 src/timer/ngage/SDL_systimer.cpp            |  2 +-
 src/timer/unix/SDL_systimer.c               | 12 +--
 src/video/SDL_blit.h                        |  2 +-
 src/video/SDL_blit_A.c                      | 22 +++---
 src/video/SDL_blit_N.c                      |  4 +-
 src/video/SDL_blit_copy.c                   |  8 +-
 src/video/SDL_egl.c                         | 10 +--
 src/video/SDL_fillrect.c                    | 12 +--
 src/video/SDL_stretch.c                     | 10 +--
 src/video/SDL_video.c                       | 14 ++--
 src/video/SDL_yuv.c                         | 24 +++---
 src/video/cocoa/SDL_cocoakeyboard.m         |  2 +-
 src/video/cocoa/SDL_cocoamodes.m            |  2 +-
 src/video/cocoa/SDL_cocoamouse.m            |  2 +-
 src/video/cocoa/SDL_cocoashape.m            |  2 +-
 src/video/cocoa/SDL_cocoavideo.m            |  2 +-
 src/video/khronos/EGL/eglplatform.h         |  4 +-
 src/video/khronos/KHR/khrplatform.h         |  4 +-
 src/video/kmsdrm/SDL_kmsdrmvulkan.c         |  2 +-
 src/video/uikit/SDL_uikitvideo.m            |  2 +-
 src/video/vita/SDL_vitakeyboard.c           |  2 +-
 src/video/vita/SDL_vitavideo.c              | 36 ++++-----
 src/video/vita/SDL_vitavideo.h              |  4 +-
 src/video/vivante/SDL_vivanteplatform.h     |  2 +-
 src/video/wayland/SDL_waylanddatamanager.c  |  4 +-
 src/video/wayland/SDL_waylandmouse.h        |  2 +-
 src/video/wayland/SDL_waylandvideo.c        |  2 +-
 src/video/wayland/SDL_waylandvulkan.c       |  2 +-
 src/video/wayland/SDL_waylandwindow.c       |  4 +-
 src/video/windows/SDL_windowsvideo.c        |  2 +-
 src/video/windows/SDL_windowswindow.c       |  2 +-
 src/video/x11/SDL_x11mouse.c                |  2 +-
 src/video/x11/SDL_x11sym.h                  |  2 +-
 src/video/x11/SDL_x11video.c                |  2 +-
 src/video/x11/SDL_x11vulkan.c               |  2 +-
 src/video/yuv2rgb/yuv_rgb.c                 |  2 +-
 test/testautomation_intrinsics.c            | 36 ++++-----
 test/testautomation_platform.c              |  4 +-
 test/testautomation_rwops.c                 |  4 +-
 test/testautomation_stdlib.c                | 10 +--
 test/testgles.c                             |  2 +-
 test/testgles2.c                            |  2 +-
 test/testgles2_sdf.c                        |  2 +-
 test/testlock.c                             | 10 +--
 129 files changed, 450 insertions(+), 450 deletions(-)

diff --git a/cmake/test/main_lib.c b/cmake/test/main_lib.c
index 9468d71f1cdc..f33c4ef8b2e5 100644
--- a/cmake/test/main_lib.c
+++ b/cmake/test/main_lib.c
@@ -4,7 +4,7 @@
 
 #include EXPORT_HEADER
 
-#if defined(_WIN32)
+#ifdef _WIN32
 #include <windows.h>
 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) {
     return TRUE;
diff --git a/include/SDL3/SDL_assert.h b/include/SDL3/SDL_assert.h
index 6fc5fa5002ca..12eb6356754e 100644
--- a/include/SDL3/SDL_assert.h
+++ b/include/SDL3/SDL_assert.h
@@ -53,7 +53,7 @@ on the assertion line and not in some random guts of SDL, and so each
 assert can have unique static variables associated with it.
 */
 
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
 /* Don't include intrin.h here because it contains C++ code */
     extern void __cdecl __debugbreak(void);
     #define SDL_TriggerBreakpoint() __debugbreak()
@@ -150,7 +150,7 @@ typedef struct SDL_AssertData
 extern DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *data,
                                                             const char *func,
                                                             const char *file, int line)
-#if defined(__clang__)
+#ifdef __clang__
 #if __has_feature(attribute_analyzer_noreturn)
    __attribute__((analyzer_noreturn))
 #endif
diff --git a/include/SDL3/SDL_begin_code.h b/include/SDL3/SDL_begin_code.h
index b6d30b521d80..99d7aa765a14 100644
--- a/include/SDL3/SDL_begin_code.h
+++ b/include/SDL3/SDL_begin_code.h
@@ -99,7 +99,7 @@
 #endif /* Compiler needs structure packing set */
 
 #ifndef SDL_INLINE
-#if defined(__GNUC__)
+#ifdef __GNUC__
 #define SDL_INLINE __inline__
 #elif defined(_MSC_VER) || defined(__BORLANDC__) || \
       defined(__DMC__) || defined(__SC__) || \
@@ -118,7 +118,7 @@
 #endif /* SDL_INLINE not defined */
 
 #ifndef SDL_FORCE_INLINE
-#if defined(_MSC_VER)
+#ifdef _MSC_VER
 #define SDL_FORCE_INLINE __forceinline
 #elif ( (defined(__GNUC__) && (__GNUC__ >= 4)) || defined(__clang__) )
 #define SDL_FORCE_INLINE __attribute__((always_inline)) static __inline__
@@ -128,7 +128,7 @@
 #endif /* SDL_FORCE_INLINE not defined */
 
 #ifndef SDL_NORETURN
-#if defined(__GNUC__)
+#ifdef __GNUC__
 #define SDL_NORETURN __attribute__((noreturn))
 #elif defined(_MSC_VER)
 #define SDL_NORETURN __declspec(noreturn)
@@ -138,7 +138,7 @@
 #endif /* SDL_NORETURN not defined */
 
 /* Apparently this is needed by several Windows compilers */
-#if !defined(__MACH__)
+#ifndef __MACH__
 #ifndef NULL
 #ifdef __cplusplus
 #define NULL 0
@@ -153,7 +153,7 @@
     (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L)
 #define SDL_FALLTHROUGH [[fallthrough]]
 #else
-#if defined(__has_attribute)
+#ifdef __has_attribute
 #define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__)
 #else
 #define SDL_HAS_FALLTHROUGH 0
diff --git a/include/SDL3/SDL_intrin.h b/include/SDL3/SDL_intrin.h
index 9f9f72246f44..addda91eecd5 100644
--- a/include/SDL3/SDL_intrin.h
+++ b/include/SDL3/SDL_intrin.h
@@ -60,13 +60,13 @@ _m_prefetch(void *__P)
 #define SDL_ALTIVEC_INTRINSICS 1
 #include <altivec.h>
 #endif
-#if !defined(SDL_DISABLE_NEON)
-#  if defined(__ARM_NEON)
+#ifndef SDL_DISABLE_NEON
+#  ifdef __ARM_NEON
 #    define SDL_NEON_INTRINSICS 1
 #    include <arm_neon.h>
 #  elif defined(__WINDOWS__) || defined(__WINRT__) || defined(__GDK__)
 /* Visual Studio doesn't define __ARM_ARCH, but _M_ARM (if set, always 7), and _M_ARM64 (if set, always 1). */
-#    if defined(_M_ARM)
+#    ifdef _M_ARM
 #      define SDL_NEON_INTRINSICS 1
 #      include <armintr.h>
 #      include <arm_neon.h>
@@ -99,7 +99,7 @@ _m_prefetch(void *__P)
 # define SDL_TARGETING(x)
 #endif
 
-#if defined(__loongarch64)
+#ifdef __loongarch64
 # ifndef SDL_DISABLE_LSX
 #  define SDL_LSX_INTRINSICS 1
 #  include <lsxintrin.h>
diff --git a/include/SDL3/SDL_main.h b/include/SDL3/SDL_main.h
index 2e560b0fa3a2..40ecb1af867b 100644
--- a/include/SDL3/SDL_main.h
+++ b/include/SDL3/SDL_main.h
@@ -31,7 +31,7 @@
  */
 
 #ifndef SDL_MAIN_HANDLED
-#if defined(__WIN32__)
+#ifdef __WIN32__
 /* On Windows SDL provides WinMain(), which parses the command line and passes
    the arguments to your main function.
 
@@ -253,7 +253,7 @@ extern DECLSPEC void SDLCALL SDL_UnregisterApp(void);
 
 #endif /* __WINRT__ */
 
-#if defined(__IOS__)
+#ifdef __IOS__
 
 /* for compatibility with SDL2's function of this name */
 #define SDL_UIKitRunApp(ARGC, ARGV, MAIN_FUNC)  SDL_RunApp(ARGC, ARGV, MAIN_FUNC, NULL)
diff --git a/include/SDL3/SDL_main_impl.h b/include/SDL3/SDL_main_impl.h
index fe262e36cc81..6b73bbb3f6d7 100644
--- a/include/SDL3/SDL_main_impl.h
+++ b/include/SDL3/SDL_main_impl.h
@@ -22,7 +22,7 @@
 #ifndef SDL_main_impl_h_
 #define SDL_main_impl_h_
 
-#if !defined(SDL_main_h_)
+#ifndef SDL_main_h_
 #error "This header should not be included directly, but only via SDL_main.h!"
 #endif
 
diff --git a/include/SDL3/SDL_opengl.h b/include/SDL3/SDL_opengl.h
index 75c665a6403d..f771f3eaf139 100644
--- a/include/SDL3/SDL_opengl.h
+++ b/include/SDL3/SDL_opengl.h
@@ -68,7 +68,7 @@
 #ifndef __gl_h_
 #define __gl_h_
 
-#if defined(USE_MGL_NAMESPACE)
+#ifdef USE_MGL_NAMESPACE
 #include <SDL3/gl_mangle.h>
 #endif
 
diff --git a/include/SDL3/SDL_platform_defines.h b/include/SDL3/SDL_platform_defines.h
index f1bb0be7e19b..e84fd8d86772 100644
--- a/include/SDL3/SDL_platform_defines.h
+++ b/include/SDL3/SDL_platform_defines.h
@@ -28,11 +28,11 @@
 #ifndef SDL_platform_defines_h_
 #define SDL_platform_defines_h_
 
-#if defined(_AIX)
+#ifdef _AIX
 #undef __AIX__
 #define __AIX__     1
 #endif
-#if defined(__HAIKU__)
+#ifdef __HAIKU__
 #undef __HAIKU__
 #define __HAIKU__   1
 #endif
@@ -40,7 +40,7 @@
 #undef __BSDI__
 #define __BSDI__    1
 #endif
-#if defined(_arch_dreamcast)
+#ifdef _arch_dreamcast
 #undef __DREAMCAST__
 #define __DREAMCAST__   1
 #endif
@@ -65,12 +65,12 @@
 #undef __LINUX__ /* do we need to do this? */
 #define __ANDROID__ 1
 #endif
-#if defined(__NGAGE__)
+#ifdef __NGAGE__
 #undef __NGAGE__
 #define __NGAGE__ 1
 #endif
 
-#if defined(__APPLE__)
+#ifdef __APPLE__
 /* lets us know what version of macOS we're compiling on */
 #include <AvailabilityMacros.h>
 #include <TargetConditionals.h>
@@ -111,11 +111,11 @@
 #endif /* TARGET_OS_IPHONE */
 #endif /* defined(__APPLE__) */
 
-#if defined(__NetBSD__)
+#ifdef __NetBSD__
 #undef __NETBSD__
 #define __NETBSD__  1
 #endif
-#if defined(__OpenBSD__)
+#ifdef __OpenBSD__
 #undef __OPENBSD__
 #define __OPENBSD__ 1
 #endif
@@ -127,7 +127,7 @@
 #undef __OSF__
 #define __OSF__     1
 #endif
-#if defined(__QNXNTO__)
+#ifdef __QNXNTO__
 #undef __QNXNTO__
 #define __QNXNTO__  1
 #endif
@@ -187,7 +187,7 @@
 #endif
 #endif /* defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__) */
 
-#if defined(__WINDOWS__)
+#ifdef __WINDOWS__
 #undef __WIN32__
 #define __WIN32__ 1
 #endif
@@ -196,19 +196,19 @@
 #undef __GDK__
 #define __GDK__ 1
 #endif
-#if defined(__PSP__)
+#ifdef __PSP__
 #undef __PSP__
 #define __PSP__ 1
 #endif
-#if defined(PS2)
+#ifdef PS2
 #define __PS2__ 1
 #endif
 
-#if defined(__vita__)
+#ifdef __vita__
 #define __VITA__ 1
 #endif
 
-#if defined(__3DS__)
+#ifdef __3DS__
 #undef __3DS__
 #define __3DS__ 1
 #endif
diff --git a/include/SDL3/SDL_rwops.h b/include/SDL3/SDL_rwops.h
index ed024055a57d..664195ac2b13 100644
--- a/include/SDL3/SDL_rwops.h
+++ b/include/SDL3/SDL_rwops.h
@@ -103,7 +103,7 @@ typedef struct SDL_RWops
     Uint32 type;
     union
     {
-#if defined(__ANDROID__)
+#ifdef __ANDROID__
         struct
         {
             void *asset;
diff --git a/include/SDL3/SDL_stdinc.h b/include/SDL3/SDL_stdinc.h
index d75bf2fac942..404e77920afb 100644
--- a/include/SDL3/SDL_stdinc.h
+++ b/include/SDL3/SDL_stdinc.h
@@ -37,8 +37,8 @@
 #include <stdint.h>
 #include <wchar.h>
 
-#if !defined(alloca)
-# if defined(HAVE_ALLOCA_H)
+#ifndef alloca
+# ifdef HAVE_ALLOCA_H
 #  include <alloca.h>
 # elif defined(__GNUC__)
 #  define alloca __builtin_alloca
@@ -309,7 +309,7 @@ typedef uint64_t Uint64;
 #define SDL_PRINTF_FORMAT_STRING
 #define SDL_SCANF_FORMAT_STRING
 #endif
-#if defined(__GNUC__)
+#ifdef __GNUC__
 #define SDL_PRINTF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __printf__, fmtargnumber, fmtargnumber+1 )))
 #define SDL_SCANF_VARARG_FUNC( fmtargnumber ) __attribute__ (( format( __scanf__, fmtargnumber, fmtargnumber+1 )))
 #else
@@ -319,7 +319,7 @@ typedef uint64_t Uint64;
 #endif /* SDL_DISABLE_ANALYZE_MACROS */
 
 #ifndef SDL_COMPILE_TIME_ASSERT
-#if defined(__cplusplus)
+#ifdef __cplusplus
 #if (__cplusplus >= 201103L)
 #define SDL_COMPILE_TIME_ASSERT(name, x)  static_assert(x, #x)
 #endif
diff --git a/include/SDL3/SDL_system.h b/include/SDL3/SDL_system.h
index a85f4a182c44..b934066f8339 100644
--- a/include/SDL3/SDL_system.h
+++ b/include/SDL3/SDL_system.h
@@ -622,7 +622,7 @@ extern DECLSPEC void SDLCALL SDL_OnApplicationDidChangeStatusBarOrientation(void
 #endif
 
 /* Functions used only by GDK */
-#if defined(__GDK__)
+#ifdef __GDK__
 typedef struct XTaskQueueObject * XTaskQueueHandle;
 
 /**
diff --git a/include/SDL3/SDL_syswm.h b/include/SDL3/SDL_syswm.h
index 72bbd16e0857..518384db52a7 100644
--- a/include/SDL3/SDL_syswm.h
+++ b/include/SDL3/SDL_syswm.h
@@ -45,7 +45,7 @@
 /**
  *  The available subsystems based on platform
  */
-#if !defined(SDL_DISABLE_SYSWM_PLATFORMS)
+#ifndef SDL_DISABLE_SYSWM_PLATFORMS
 
 #ifndef SDL_DISABLE_SYSWM_ANDROID
 #ifdef __ANDROID__
@@ -227,7 +227,7 @@ struct SDL_SysWMmsg
 
     union
     {
-#if defined(SDL_ENABLE_SYSWM_WINDOWS)
+#ifdef SDL_ENABLE_SYSWM_WINDOWS
         struct {
             HWND hwnd;                  /**< The window for the message */
             UINT msg;                   /**< The type of message */
@@ -235,7 +235,7 @@ struct SDL_SysWMmsg
             LPARAM lParam;              /**< LONG message parameter */
         } win;
 #endif
-#if defined(SDL_ENABLE_SYSWM_X11)
+#ifdef SDL_ENABLE_SYSWM_X11
         struct {
             XEvent event;
         } x11;
@@ -260,7 +260,7 @@ struct SDL_SysWMinfo
 
     union
     {
-#if defined(SDL_ENABLE_SYSWM_WINDOWS)
+#ifdef SDL_ENABLE_SYSWM_WINDOWS
         struct
         {
             HWND window;                /**< The window handle */
@@ -268,13 +268,13 @@ struct SDL_SysWMinfo
             HINSTANCE hinstance;        /**< The instance handle */
         } win;
 #endif
-#if defined(SDL_ENABLE_SYSWM_WINRT)
+#ifdef SDL_ENABLE_SYSWM_WINRT
         struct
         {
             IInspectable * window;      /**< The WinRT CoreWindow */
         } winrt;
 #endif
-#if defined(SDL_ENABLE_SYSWM_X11)
+#ifdef SDL_ENABLE_SYSWM_X11
         struct
         {
             Display *display;           /**< The X11 display */
@@ -282,7 +282,7 @@ struct SDL_SysWMinfo
             Window window;              /**< The X11 window */
         } x11;
 #endif
-#if defined(SDL_ENABLE_SYSWM_COCOA)
+#ifdef SDL_ENABLE_SYSWM_COCOA
         struct
         {
 #if defined(__OBJC__) && defined(__has_feature)
@@ -296,7 +296,7 @@ struct SDL_SysWMinfo
 #endif
         } cocoa;
 #endif
-#if defined(SDL_ENABLE_SYSWM_UIKIT)
+#ifdef SDL_ENABLE_SYSWM_UIKIT
         struct
         {
 #if defined(__OBJC__) && defined(__has_feature)
@@ -313,7 +313,7 @@ struct SDL_SysWMinfo
             GLuint resolveFramebuffer; /**< The Framebuffer Object which holds the resolve color Renderbuffer, when MSAA is used. */
         } uikit;
 #endif
-#if defined(SDL_ENABLE_SYSWM_WAYLAND)
+#ifdef SDL_ENABLE_SYSWM_WAYLAND
         struct
         {
             struct wl_display *display;             /**< Wayland display */
@@ -326,7 +326,7 @@ struct SDL_SysWMinfo
         } wl;
 #endif
 
-#if defined(SDL_ENABLE_SYSWM_ANDROID)
+#ifdef SDL_ENABLE_SYSWM_ANDROID
         struct
         {
             ANativeWindow *window;
@@ -334,7 +334,7 @@ struct SDL_SysWMinfo
         } android;
 #endif
 
-#if defined(SDL_ENABLE_SYSWM_VIVANTE)
+#ifdef SDL_ENABLE_SYSWM_VIVANTE
         struct
         {
             EGLNativeDisplayType display;
@@ -342,7 +342,7 @@ struct SDL_SysWMinfo
         } vivante;
 #endif
 
-#if defined(SDL_ENABLE_SYSWM_KMSDRM)
+#ifdef SDL_ENABLE_SYSWM_KMSDRM
         struct
         {
             int dev_index;               /**< Device index (ex: the X in /dev/dri/cardX) */
diff --git a/include/SDL3/SDL_test_common.h b/include/SDL3/SDL_test_common.h
index 84dd18aeef49..c326732b9e60 100644
--- a/include/SDL3/SDL_test_common.h
+++ b/include/SDL3/SDL_test_common.h
@@ -34,7 +34,7 @@
 
 #include <SDL3/SDL.h>
 
-#if defined(__PSP__)
+#ifdef __PSP__
 #define DEFAULT_WINDOW_WIDTH  480
 #define DEFAULT_WINDOW_HEIGHT 272
 #elif defined(__VITA__)
diff --git a/src/SDL.c b/src/SDL.c
index 70f8dd3d3d8d..d364b9df6f9e 100644
--- a/src/SDL.c
+++ b/src/SDL.c
@@ -30,7 +30,7 @@
 /* this checks for HAVE_DBUS_DBUS_H internally. */
 #include "core/linux/SDL_dbus.h"
 
-#if defined(__EMSCRIPTEN__)
+#ifdef __EMSCRIPTEN__
 #include <emscripten.h>
 #endif
 
@@ -548,7 +548,7 @@ SDL_GetRevision(void)
 const char *
 SDL_GetPlatform(void)
 {
-#if defined(__AIX__)
+#ifdef __AIX__
     return "AIX";
 #elif defined(__ANDROID__)
     return "Android";
@@ -620,7 +620,7 @@ SDL_GetPlatform(void)
 SDL_bool
 SDL_IsTablet(void)
 {
-#if defined(__ANDROID__)
+#ifdef __ANDROID__
     extern SDL_bool SDL_IsAndroidTablet(void);
     return SDL_IsAndroidTablet();
 #elif defined(__IOS__)
@@ -631,7 +631,7 @@ SDL_IsTablet(void)
 #endif
 }
 
-#if defined(__WIN32__)
+#ifdef __WIN32__
 
 #if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
 /* Need to include DllMain() on Watcom C for some reason.. */
diff --git a/src/SDL_assert.c b/src/SDL_assert.c
index d243f66bd328..10253987cc3b 100644
--- a/src/SDL_assert.c
+++ b/src/SDL_assert.c
@@ -33,7 +33,7 @@
 #endif
 #endif
 
-#if defined(__EMSCRIPTEN__)
+#ifdef __EMSCRIPTEN__
 #include <emscripten.h>
 #endif
 
@@ -123,13 +123,13 @@ static void SDL_GenerateAssertionReport(void)
 /* This is not declared in any header, although it is shared between some
     parts of SDL, because we don't want anything calling it without an
     extremely good reason. */
-#if defined(__WATCOMC__)
+#ifdef __WATCOMC__
 extern void SDL_ExitProcess(int exitcode);
 #pragma aux SDL_ExitProcess aborts;
 #endif
 extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
 
-#if defined(__WATCOMC__)
+#ifdef __WATCOMC__
 static void SDL_AbortAssertion(void);
 #pragma aux SDL_AbortAssertion aborts;
 #endif
@@ -238,7 +238,7 @@ static SDL_AssertState SDLCALL SDL_PromptAssertion(const SDL_AssertData *data, v
             state = (SDL_AssertState)selected;
         }
     } else {
-#if defined(__EMSCRIPTEN__)
+#ifdef __EMSCRIPTEN__
         /* This is nasty, but we can't block on a custom UI. */
         for (;;) {
             SDL_bool okay = SDL_TRUE;
diff --git a/src/SDL_internal.h b/src/SDL_internal.h
index 08fb8398c380..7dfcdc85978b 100644
--- a/src/SDL_internal.h
+++ b/src/SDL_internal.h
@@ -75,15 +75,15 @@
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
-#if defined(HAVE_STDLIB_H)
+#ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #elif defined(HAVE_MALLOC_H)
 #include <malloc.h>
 #endif
-#if defined(HAVE_STDDEF_H)
+#ifdef HAVE_STDDEF_H
 #include <stddef.h>
 #endif
-#if defined(HAVE_STDARG_H)
+#ifdef HAVE_STDARG_H
 #include <stdarg.h>
 #endif
 #ifdef HAVE_STRING_H
@@ -98,7 +98,7 @@
 #ifdef HAVE_WCHAR_H
 #include <wchar.h>
 #endif
-#if defined(HAVE_INTTYPES_H)
+#ifdef HAVE_INTTYPES_H
 #include <inttypes.h>
 #elif defined(HAVE_STDINT_H)
 #include <stdint.h>
diff --git a/src/SDL_log.c b/src/SDL_log.c
index 9988b180fcc9..7d17186a3f77 100644
--- a/src/SDL_log.c
+++ b/src/SDL_log.c
@@ -32,7 +32,7 @@
 #include <stdio.h>
 #endif
 
-#if defined(__ANDROID__)
+#ifdef __ANDROID__
 #include <android/log.h>
 #endif
 
diff --git a/src/atomic/SDL_atomic.c b/src/atomic/SDL_atomic.c
index 061061661a48..b22fc906fecc 100644
--- a/src/atomic/SDL_atomic.c
+++ b/src/atomic/SDL_atomic.c
@@ -25,7 +25,7 @@
 #define HAVE_MSC_ATOMICS 1
 #endif
 
-#if defined(__MACOS__) /* !!! FIXME: should we favor gcc atomics? */
+#ifdef __MACOS__ /* !!! FIXME: should we favor gcc atomics? */
 #include <libkern/OSAtomic.h>
 #endif
 
@@ -34,11 +34,11 @@
 #endif
 
 /* The __atomic_load_n() intrinsic showed up in different times for different compilers. */
-#if defined(__clang__)
+#ifdef __clang__
 #if __has_builtin(__atomic_load_n) || defined(HAVE_GCC_ATOMICS)
 /* !!! FIXME: this advertises as available in the NDK but uses an external symbol we don't have.
    It might be in a later NDK or we might need an extra library? --ryan. */
-#if !defined(__ANDROID__)
+#ifndef __ANDROID__
 #define HAVE_ATOMIC_LOAD_N 1
 #endif
 #endif
@@ -155,7 +155,7 @@ SDL_AtomicCAS(SDL_AtomicInt *a, int oldval, int newval)
 SDL_bool
 SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
 {
-#if defined(HAVE_MSC_ATOMICS)
+#ifdef HAVE_MSC_ATOMICS
     return _InterlockedCompareExchangePointer(a, newval, oldval) == oldval;
 #elif defined(HAVE_WATCOM_ATOMICS)
     return (SDL_bool)_SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
@@ -206,7 +206,7 @@ int SDL_AtomicSet(SDL_AtomicInt *a, int v)
 void *
 SDL_AtomicSetPtr(void **a, void *v)
 {
-#if defined(HAVE_MSC_ATOMICS)
+#ifdef HAVE_MSC_ATOMICS
     return _InterlockedExchangePointer(a, v);
 #elif defined(HAVE_WATCOM_ATOMICS)
     return (void *)_SDL_xchg_watcom((int *)a, (long)v);
diff --git a/src/atomic/SDL_spinlock.c b/src/atomic/SDL_spinlock.c
index 8c9b7f31dca0..25ae1d0ddcdb 100644
--- a/src/atomic/SDL_spinlock.c
+++ b/src/atomic/SDL_spinlock.c
@@ -36,7 +36,7 @@
 #include <xmmintrin.h>
 #endif
 
-#if defined(PS2)
+#ifdef PS2
 #include <kernel.h>
 #endif
 
@@ -60,7 +60,7 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
 SDL_bool
 SDL_AtomicTryLock(SDL_SpinLock *lock)
 {
-#if defined(SDL_ATOMIC_DISABLED)
+#ifdef SDL_ATOMIC_DISABLED
     /* Terrible terrible damage */
     static SDL_mutex *_spinlock_mutex;
 
@@ -98,7 +98,7 @@ SDL_AtomicTryLock(SDL_SpinLock *lock)
      defined(__ARM_ARCH_5TEJ__))
     int result;
 
-#if defined(__RISCOS__)
+#ifdef __RISCOS__
     if (__cpucap_have_rex()) {
         __asm__ __volatile__(
             "ldrex %0, [%2]\nteq   %0, #0\nstrexeq %0, %1, [%2]"
diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c
index 8ae372ed536b..aca42620619e 100644
--- a/src/audio/SDL_audio.c
+++ b/src/audio/SDL_audio.c
@@ -646,7 +646,7 @@ static int SDLCALL SDL_RunAudio(void *devicep)
 
     SDL_assert(!device->iscapture);
 
-#if defined(SDL_AUDIO_DRIVER_ANDROID)
+#ifdef SDL_AUDIO_DRIVER_ANDROID
     {
         /* Set thread priority to THREAD_PRIORITY_AUDIO */
         Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
@@ -746,7 +746,7 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
 
     SDL_assert(device->iscapture);
 
-#if defined(SDL_AUDIO_DRIVER_ANDROID)
+#ifdef SDL_AUDIO_DRIVER_ANDROID
     {
         /* Set thread priority to THREAD_PRIORITY_AUDIO */
         Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
diff --git a/src/audio/SDL_audiocvt.c b/src/audio/SDL_audiocvt.c
index b8df58ad0e7e..413f5e7975e8 100644
--- a/src/audio/SDL_audiocvt.c
+++ b/src/audio/SDL_audiocvt.c
@@ -144,7 +144,7 @@ static int SDL_ConvertAudio(SDL_AudioCVT * cvt);
  * 8 channels (7.1) layout: FL+FR+FC+LFE+BL+BR+SL+SR
  */
 
-#if defined(SDL_SSE3_INTRINSICS)
+#ifdef SDL_SSE3_INTRINSICS
 /* Convert from stereo to mono. Average left and right. */
 static void SDLCALL SDL_TARGETING("sse3") SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
@@ -181,7 +181,7 @@ static void SDLCALL SDL_TARGETING("sse3") SDL_ConvertStereoToMono_SSE3(SDL_Audio
 }
 #endif
 
-#if defined(SDL_SSE_INTRINSICS)
+#ifdef SDL_SSE_INTRINSICS
 /* Convert from mono to stereo. Duplicate to stereo left and right. */
 static void SDLCALL SDL_TARGETING("sse") SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
@@ -834,7 +834,7 @@ static int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
         /* swap in some SIMD versions for a few of these. */
         if (channel_converter == SDL_ConvertStereoToMono) {
             SDL_AudioFilter filter = NULL;
-#if defined(SDL_SSE3_INTRINSICS)
+#ifdef SDL_SSE3_INTRINSICS
             if (!filter && SDL_HasSSE3()) {
                 filter = SDL_ConvertStereoToMono_SSE3;
             }
@@ -844,7 +844,7 @@ static int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
             }
         } else if (channel_converter == SDL_ConvertMonoToStereo) {
             SDL_AudioFilter filter = NULL;
-#if defined(SDL_SSE_INTRINSICS)
+#ifdef SDL_SSE_INTRINSICS
             if (!filter && SDL_HasSSE()) {
                 filter = SDL_ConvertMonoToStereo_SSE;
             }
diff --git a/src/audio/SDL_audiotypecvt.c b/src/audio/SDL_audiotypecvt.c
index 6cfe98ea564f..48e0085d33bd 100644
--- a/src/audio/SDL_audiotypecvt.c
+++ b/src/audio/SDL_audiotypecvt.c
@@ -226,7 +226,7 @@ static void SDLCALL SDL_Convert_F32_to_S32_Scalar(SDL_AudioCVT *cvt, SDL_AudioFo
 }
 #endif
 
-#if defined(SDL_SSE2_INTRINSICS)
+#ifdef SDL_SSE2_INTRINSICS
 static void SDLCALL SDL_TARGETING("sse2") SDL_Convert_S8_to_F32_SSE2(SDL_AudioCVT *cvt, SDL_AudioFormat format)
 {
     const Sint8 *src = ((const Sint8 *)(cvt->buf + cvt->len_cvt)) - 1;
@@ -1175,7 +1175,7 @@ void SDL_ChooseAudioConverters(void)
     SDL_Convert_F32_to_S32 = SDL_Convert_F32_to_S32_##fntype; \
     converters_chosen = SDL_TRUE
 
-#if defined(SDL_SSE2_INTRINSICS)
+#ifdef SDL_SSE2_INTRINSICS
     if (SDL_HasSSE2()) {
         SET_CONVERTER_FUNCS(SSE2);
         return;
diff --git a/src/audio/coreaudio/SDL_coreaudio.h b/src/audio/coreaudio/SDL_coreaudio.h
index e9565a9d265e..8509a246d0ff 100644
--- a/src/audio/coreaudio/SDL_coreaudio.h
+++ b/src/audio/coreaudio/SDL_coreaudio.h
@@ -25,7 +25,7 @@
 
 #include "../SDL_sysaudio.h"
 
-#if !defined(__IOS__)
+#ifndef __IOS__
 #define MACOSX_COREAUDIO
 #endif
 
diff --git a/src/audio/coreaudio/SDL_coreaudio.m b/src/audio/coreaudio/SDL_coreaudio.m
index a105efebc360..48573f96a778 100644
--- a/src/audio/coreaudio/SDL_coreaudio.m
+++ b/src/audio/coreaudio/SDL_coreaudio.m
@@ -891,7 +891,7 @@ static int prepare_audioqueue(_THIS)
 
     /* Make sure we can feed the device a minimum amount of time */
     MINIMUM_AUDIO_BUFFER_TIME_MS = 15.0;
-#if defined(__IOS__)
+#ifdef __IOS__
     if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_7_1) {
         /* Older iOS hardware, use 40 ms as a minimum time */
         MINIMUM_AUDIO_BUFFER_TIME_MS = 40.0;
diff --git a/src/audio/directsound/SDL_directsound.c b/src/audio/directsound/SDL_directsound.c
index 39e3f334f5f5..176e9e90bba7 100644
--- a/src/audio/directsound/SDL_directsound.c
+++ b/src/audio/directsound/SDL_directsound.c
@@ -186,14 +186,14 @@ static BOOL CALLBACK FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVO
 
 static void DSOUND_DetectDevices(void)
 {
-#if defined(HAVE_MMDEVICEAPI_H)
+#ifdef HAVE_MMDEVICEAPI_H
     if (SupportsIMMDevice) {
         SDL_IMMDevice_EnumerateEndpoints(SDL_TRUE);
     } else {
 #endif /* HAVE_MMDEVICEAPI_H */
         pDirectSoundCaptureEnumerateW(FindAllDevs, (void *)((size_t)1));
         pDirectSoundEnumerateW(FindAllDevs, (void *)((size_t)0));
-#if defined(HAVE_MMDEVICEAPI_H)
+#ifdef HAVE_MMDEVICEAPI_H
     }
 #endif /* HAVE_MMDEVICEAPI_H*/
 }
@@ -609,7 +609,7 @@ static int DSOUND_OpenDevice(_THIS, const char *devname)
 
 static void DSOUND_Deinitialize(void)
 {
-#if defined(HAVE_MMDEVICEAPI_H)
+#ifdef HAVE_MMDEVICEAPI_H
     if (SupportsIMMDevice) {
         SDL_IMMDevice_Quit();
         SupportsIMMDevice = SDL_FALSE;
@@ -624,7 +624,7 @@ static SDL_bool DSOUND_Init(SDL_AudioDriverImpl *impl)
         return SDL_FALSE;
     }
 
-#if defined(HAVE_MMDEVICEAPI_H)
+#ifdef HAVE_MMDEVICEAPI_H
     SupportsIMMDevice = !(SDL_IMMDevice_Init() < 0);
 #endif /* HAVE_MMDEVICEAPI_H */
 
diff --git a/src/audio/netbsd/SDL_netbsdaudio.c b/src/audio/netbsd/SDL_netbsdaudio.c
index b54fac662c4b..13e333954c46 100644
--- a/src/audio/netbsd/SDL_netbsdaudio.c
+++ b/src/audio/netbsd/SDL_netbsdaudio.c
@@ -20,7 +20,7 @@
 */
 #include "SDL_internal.h"
 
-#if defined(SDL_AUDIO_DRIVER_NETBSD)
+#ifdef SDL_AUDIO_DRIVER_NETBSD
 
 /*
  * Driver for native NetBSD audio(4).
diff --git a/src/core/haiku/SDL_BeApp.cc b/src/core/haiku/SDL_BeApp.cc
index 5fddc8d31f57..0dff28ffd64a 100644
--- a/src/core/haiku/SDL_BeApp.cc
+++ b/src/core/haiku/SDL_BeApp.cc
@@ -20,7 +20,7 @@
 */
 #include "SDL_internal.h"
 
-#if defined(__HAIKU__)
+#ifdef __HAIKU__
 
 /* Handle the BeApp specific portions of the application */
 
diff --git a/src/core/linux/SDL_fcitx.c b/src/core

(Patch may be truncated, please check the link at the top of this post.)