From d7e1672ae767c97c0edaaf0a56ce323b1fafa82e Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Mon, 7 Jul 2025 23:54:55 +0300 Subject: [PATCH] Always define typeof to __typeof__, unless targeting C23. Fixes #710 --- Core/defs.h | 7 ++++++- Core/gb.h | 3 --- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Core/defs.h b/Core/defs.h index 29fb5dd3f..5f279e23f 100644 --- a/Core/defs.h +++ b/Core/defs.h @@ -4,13 +4,18 @@ #define GB_unlikely(x) __builtin_expect((bool)(x), 0) #define GB_inline_const(type, ...) (*({static const typeof(type) _= __VA_ARGS__; &_;})) +#if !defined(typeof) +#if defined(__cplusplus) || __STDC_VERSION__ < 202311 +#define typeof __typeof__ +#endif +#endif + #ifdef GB_INTERNAL // "Keyword" definitions #define likely(x) GB_likely(x) #define unlikely(x) GB_unlikely(x) #define inline_const GB_inline_const -#define typeof __typeof__ #if !defined(MIN) #define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; }) diff --git a/Core/gb.h b/Core/gb.h index f3b49bec6..447a16761 100644 --- a/Core/gb.h +++ b/Core/gb.h @@ -1,9 +1,6 @@ #pragma once #ifdef __cplusplus -#if defined(__STRICT_ANSI__) && !defined(typeof) -#define typeof decltype -#endif extern "C" { #endif