From d768dae402c8fad503aebd24dc17c38dbfa0b1e3 Mon Sep 17 00:00:00 2001 From: Lam Wei Lun Date: Thu, 30 Apr 2026 00:02:49 +0800 Subject: [PATCH] [build] Shift `__cplusplus` check to a higher level for `bool` type define (#5804) * Adds a missing macro definition check * Shifts __cplusplus check to a higher level for bool define * Copy same change to rgestures.h and rlgl.h * Fixes float comparison issues in raymath functions * Revert "Fixes float comparison issues in raymath functions" This reverts commit a266d0bbaae4a692deb48dae5f6c528a3b3d5048. --- src/raylib.h | 4 +++- src/rgestures.h | 5 ++++- src/rlgl.h | 8 +++++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/raylib.h b/src/raylib.h index 48f2724e1..e8164073f 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -203,12 +203,14 @@ // Types and Structures Definition //---------------------------------------------------------------------------------- // Boolean type +#if !defined(__cplusplus) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include -#elif !defined(__cplusplus) && !defined(bool) +#elif !defined(bool) typedef enum bool { false = 0, true = !false } bool; #define RL_BOOL_TYPE #endif +#endif // Vector2, 2 components typedef struct Vector2 { diff --git a/src/rgestures.h b/src/rgestures.h index bb51d72ee..734d33f0f 100644 --- a/src/rgestures.h +++ b/src/rgestures.h @@ -59,10 +59,13 @@ // NOTE: Below types are required for standalone usage //---------------------------------------------------------------------------------- // Boolean type +#if !defined(__cplusplus) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include -#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) +#elif !defined(bool) typedef enum bool { false = 0, true = !false } bool; + #define RL_BOOL_TYPE +#endif #endif #if !defined(RL_VECTOR2_TYPE) diff --git a/src/rlgl.h b/src/rlgl.h index 539f409df..76b765e2e 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -358,11 +358,13 @@ //---------------------------------------------------------------------------------- // Types and Structures Definition //---------------------------------------------------------------------------------- +#if !defined(__cplusplus) #if (defined(__STDC__) && __STDC_VERSION__ >= 199901L) || (defined(_MSC_VER) && _MSC_VER >= 1800) #include -#elif !defined(__cplusplus) && !defined(bool) && !defined(RL_BOOL_TYPE) - // Boolean type -typedef enum bool { false = 0, true = !false } bool; +#elif !defined(bool) + typedef enum bool { false = 0, true = !false } bool; + #define RL_BOOL_TYPE +#endif #endif #if !defined(RL_MATRIX_TYPE)