Fixed bug 4392 - SDL_cpuinfo.h breaks compilation with C bool type
authorSam Lantinga <slouken@libsdl.org>
Mon, 19 Nov 2018 21:28:52 -0800
changeset 124236da95eef84a2
parent 12422 9091b20040cf
child 12424 6b3a68e3dd06
Fixed bug 4392 - SDL_cpuinfo.h breaks compilation with C bool type

Luke Dashjr

Bug 3993 was "fixed" by #undef'ing bool. But this breaks C99's stdbool.h bool too.

For example, mpv's build fails with:

../audio/out/ao_sdl.c:35:5: error: unknown type name ‘bool’

It seems ill-advised to be #undef'ing *anything* here - what if the code including SDL_cpuinfo.h actually wants to use altivec?
include/SDL_cpuinfo.h
     1.1 --- a/include/SDL_cpuinfo.h	Mon Nov 19 21:17:00 2018 -0800
     1.2 +++ b/include/SDL_cpuinfo.h	Mon Nov 19 21:28:52 2018 -0800
     1.3 @@ -50,12 +50,9 @@
     1.4  #elif defined(__MINGW64_VERSION_MAJOR)
     1.5  #include <intrin.h>
     1.6  #else
     1.7 -#ifdef __ALTIVEC__
     1.8 -#if defined(HAVE_ALTIVEC_H) && !defined(__APPLE_ALTIVEC__) && !defined(SDL_DISABLE_ALTIVEC_H)
     1.9 +/* altivec.h redefining bool causes a number of problems, see bugs 3993 and 4392, so you need to explicitly define SDL_ENABLE_ALTIVEC_H to have it included. */
    1.10 +#if defined(HAVE_ALTIVEC_H) && defined(__ALTIVEC__) && !defined(__APPLE_ALTIVEC__) && defined(SDL_ENABLE_ALTIVEC_H)
    1.11  #include <altivec.h>
    1.12 -#undef pixel
    1.13 -#undef bool
    1.14 -#endif
    1.15  #endif
    1.16  #if defined(__ARM_NEON__) && !defined(SDL_DISABLE_ARM_NEON_H)
    1.17  #include <arm_neon.h>