Always define typeof to __typeof__, unless targeting C23. Fixes #710

This commit is contained in:
Lior Halphon
2025-07-07 23:54:55 +03:00
parent bdd4522ca9
commit d7e1672ae7
2 changed files with 6 additions and 4 deletions

View File

@@ -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; })

View File

@@ -1,9 +1,6 @@
#pragma once
#ifdef __cplusplus
#if defined(__STRICT_ANSI__) && !defined(typeof)
#define typeof decltype
#endif
extern "C" {
#endif