From b8da02e6efe7c6558d6d27ad41e724653279ebc3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 18 Sep 2021 10:44:32 -0400 Subject: [PATCH] include: Fix triggering of Clang's -Wexpansion-to-defined in SDL_endian.h It doesn't like #if statements that uses a macro that uses defined(x). --- include/SDL_endian.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/include/SDL_endian.h b/include/SDL_endian.h index db72928ef..ae8fc60e6 100644 --- a/include/SDL_endian.h +++ b/include/SDL_endian.h @@ -93,16 +93,22 @@ extern "C" { */ /* various modern compilers may have builtin swap */ -#define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \ - (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))) -#define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \ - (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) -#define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \ - (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) +#if defined(__GNUC__) +# define HAS_BUILTIN_BSWAP16 (_SDL_HAS_BUILTIN(__builtin_bswap16)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)) +# define HAS_BUILTIN_BSWAP32 (_SDL_HAS_BUILTIN(__builtin_bswap32)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) +# define HAS_BUILTIN_BSWAP64 (_SDL_HAS_BUILTIN(__builtin_bswap64)) || \ + (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -/* this one is broken */ -#define HAS_BROKEN_BSWAP (defined(__GNUC__) && \ - (__GNUC__ == 2 && __GNUC_MINOR__ <= 95)) + /* this one is broken */ +# define HAS_BROKEN_BSWAP (__GNUC__ == 2 && __GNUC_MINOR__ <= 95) +#else +# define HAS_BUILTIN_BSWAP16 0 +# define HAS_BUILTIN_BSWAP32 0 +# define HAS_BUILTIN_BSWAP64 0 +# define HAS_BROKEN_BSWAP 0 +#endif #if HAS_BUILTIN_BSWAP16 #define SDL_Swap16(x) __builtin_bswap16(x)