Simple Directmedia Layer

Updated check for stdbool.h

If you're building in a C99 or newer environment, we'll automatically include stdbool.h.

If you're building in a C89 or C90 environment, we'll assume that stdbool.h isn't available and define bool as an unsigned char. If you have a working stdbool.h and want SDL to use it, you can either include stdbool.h before SDL headers, or define SDL_INCLUDE_STDBOOL_H in your project.

Closes https://github.com/libsdl-org/SDL/pull/10980

+18 -22
+14 -21
include/SDL3/SDL_stdinc.h
··· 34 34 35 35 #include <SDL3/SDL_platform_defines.h> 36 36 37 - /* Most everything except Visual Studio 2013 and earlier has stdbool.h now */ 38 - #if defined(_MSC_VER) && (_MSC_VER < 1910) 39 - #define SDL_DEFINE_STDBOOL 40 - #endif 41 - /* gcc-2.95 had non-standard stdbool.h */ 42 - #if defined(__GNUC__) && (__GNUC__ < 3) 43 - #define SDL_DEFINE_STDBOOL 44 - #endif 37 + #include <stdarg.h> 38 + #include <stdint.h> 39 + #include <string.h> 40 + #include <wchar.h> 45 41 46 - #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 42 + #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ 43 + defined(SDL_INCLUDE_INTTYPES_H) 47 44 #include <inttypes.h> 48 45 #endif 49 - #include <stdarg.h> 46 + 50 47 #ifndef __cplusplus 51 - #ifdef SDL_DEFINE_STDBOOL 52 - #ifndef __bool_true_false_are_defined 53 - #define __bool_true_false_are_defined 1 54 - #define bool uint8_t 48 + #if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ 49 + defined(SDL_INCLUDE_STDBOOL_H) 50 + #include <stdbool.h> 51 + #elif !defined(__bool_true_false_are_defined) && !defined(bool) 52 + #define bool unsigned char 55 53 #define false 0 56 54 #define true 1 55 + #define __bool_true_false_are_defined 1 57 56 #endif 58 - #else 59 - #include <stdbool.h> 60 - #endif 61 - #endif 62 - #include <stdint.h> 63 - #include <string.h> 64 - #include <wchar.h> 57 + #endif /* !__cplusplus */ 65 58 66 59 #ifndef SDL_DISABLE_ALLOCA 67 60 # ifndef alloca
+2
include/SDL3/SDL_test_crc32.h
··· 34 34 #ifndef SDL_test_crc32_h_ 35 35 #define SDL_test_crc32_h_ 36 36 37 + #include <SDL3/SDL_stdinc.h> 38 + 37 39 #include <SDL3/SDL_begin_code.h> 38 40 /* Set up for C function definitions, even when using C++ */ 39 41 #ifdef __cplusplus
+2
include/SDL3/SDL_test_memory.h
··· 30 30 #ifndef SDL_test_memory_h_ 31 31 #define SDL_test_memory_h_ 32 32 33 + #include <SDL3/SDL_stdinc.h> 34 + 33 35 #include <SDL3/SDL_begin_code.h> 34 36 /* Set up for C function definitions, even when using C++ */ 35 37 #ifdef __cplusplus
-1
src/joystick/gdk/SDL_gameinputjoystick.c
··· 25 25 #include "../SDL_sysjoystick.h" 26 26 #include "../usb_ids.h" 27 27 28 - #include <stdbool.h> 29 28 #define COBJMACROS 30 29 #include <gameinput.h> 31 30