Skip to content

Commit d7e1672

Browse files
committed
Always define typeof to __typeof__, unless targeting C23. Fixes #710
1 parent bdd4522 commit d7e1672

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

Core/defs.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,18 @@
44
#define GB_unlikely(x) __builtin_expect((bool)(x), 0)
55
#define GB_inline_const(type, ...) (*({static const typeof(type) _= __VA_ARGS__; &_;}))
66

7+
#if !defined(typeof)
8+
#if defined(__cplusplus) || __STDC_VERSION__ < 202311
9+
#define typeof __typeof__
10+
#endif
11+
#endif
12+
713
#ifdef GB_INTERNAL
814

915
// "Keyword" definitions
1016
#define likely(x) GB_likely(x)
1117
#define unlikely(x) GB_unlikely(x)
1218
#define inline_const GB_inline_const
13-
#define typeof __typeof__
1419

1520
#if !defined(MIN)
1621
#define MIN(A, B) ({ __typeof__(A) __a = (A); __typeof__(B) __b = (B); __a < __b ? __a : __b; })

Core/gb.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#pragma once
22

33
#ifdef __cplusplus
4-
#if defined(__STRICT_ANSI__) && !defined(typeof)
5-
#define typeof decltype
6-
#endif
74
extern "C" {
85
#endif
96

0 commit comments

Comments
 (0)