From f3057fd2bcb9200ce7224bf7ed521432b585a773 Mon Sep 17 00:00:00 2001 From: Yamagi Date: Sun, 11 May 2025 10:11:02 +0200 Subject: [PATCH] Fix C23 bool type being 1 byte long, while the enum bool is 4 bytes. C23 introduced `true` and `false` as language keywords, breaking YQ2s use of them. The first attempt to get C23 was to use the buildin `bool` type when building in C23 mode and the classic enum based `qboolean` in any other mode. This didn't take into acount, that `bool` is 1 byte long, while the enum based `qboolean` is 4 bytes long. This breaks savegames and may have impact for mods. Fix this by always using `int` as `qboolean` and the buildin `true` and `false` types, either in their C99 or C23 variant. This way `qboolean` is always 4 bytes long and the newly introduced `true` and `false` keywords don't clash. Suggested by @DanielGibson. --- src/header/shared.h | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/header/shared.h b/src/header/shared.h index 1c1f2fb..27fcffd 100644 --- a/src/header/shared.h +++ b/src/header/shared.h @@ -35,21 +35,9 @@ #include #include #include +#include -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000L // C23 or newer -typedef bool qboolean; -#else -#ifdef true - #undef true -#endif - -#ifdef false - #undef false -#endif - -typedef enum {false, true} qboolean; -#endif - +typedef int qboolean; typedef unsigned char byte; #ifndef NULL