Skip to content

Commit 14166e2

Browse files
committed
Add C23 check for static_assert without message
1 parent bd95e36 commit 14166e2

1 file changed

Lines changed: 30 additions & 24 deletions

File tree

Sources/OpenRenderBox/include/OpenRenderBox/ORBPathCallbacks.h

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,21 @@ typedef struct ORB_SWIFT_NAME(ORBPath.Callbacks) ORBPathCallbacks {
4646
const struct ORBPathCallbacks * _Nullable (* _Nullable next)(const void *object);
4747
} ORBPathCallbacks;
4848

49-
static_assert(sizeof(ORBPathCallbacks) == 0x58);
50-
static_assert(offsetof(ORBPathCallbacks, flags) == 0x00);
51-
static_assert(offsetof(ORBPathCallbacks, retain) == 0x08);
52-
static_assert(offsetof(ORBPathCallbacks, release) == 0x10);
53-
static_assert(offsetof(ORBPathCallbacks, apply) == 0x18);
54-
static_assert(offsetof(ORBPathCallbacks, isEqual) == 0x20);
55-
static_assert(offsetof(ORBPathCallbacks, isEmpty) == 0x28);
56-
static_assert(offsetof(ORBPathCallbacks, isSingleElement) == 0x30);
57-
static_assert(offsetof(ORBPathCallbacks, bezierOrder) == 0x38);
58-
static_assert(offsetof(ORBPathCallbacks, boundingRect) == 0x40);
59-
static_assert(offsetof(ORBPathCallbacks, cgPath) == 0x48);
60-
static_assert(offsetof(ORBPathCallbacks, next) == 0x50);
49+
// static_assert without message requires C23 or C++17
50+
#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
51+
static_assert(sizeof(struct ORBPathCallbacks) == 0x58);
52+
static_assert(offsetof(struct ORBPathCallbacks, flags) == 0x00);
53+
static_assert(offsetof(struct ORBPathCallbacks, retain) == 0x08);
54+
static_assert(offsetof(struct ORBPathCallbacks, release) == 0x10);
55+
static_assert(offsetof(struct ORBPathCallbacks, apply) == 0x18);
56+
static_assert(offsetof(struct ORBPathCallbacks, isEqual) == 0x20);
57+
static_assert(offsetof(struct ORBPathCallbacks, isEmpty) == 0x28);
58+
static_assert(offsetof(struct ORBPathCallbacks, isSingleElement) == 0x30);
59+
static_assert(offsetof(struct ORBPathCallbacks, bezierOrder) == 0x38);
60+
static_assert(offsetof(struct ORBPathCallbacks, boundingRect) == 0x40);
61+
static_assert(offsetof(struct ORBPathCallbacks, cgPath) == 0x48);
62+
static_assert(offsetof(struct ORBPathCallbacks, next) == 0x50);
63+
#endif
6164

6265
/// Extended callbacks structure with additional extended callbacks argument
6366
typedef struct ORB_SWIFT_NAME(ORBPath.CallbacksExtended) ORBPathCallbacksExtended {
@@ -78,18 +81,21 @@ typedef struct ORB_SWIFT_NAME(ORBPath.CallbacksExtended) ORBPathCallbacksExtende
7881
const struct ORBPathCallbacksExtended * _Nullable (* _Nullable next)(const void *object, const struct ORBPathCallbacksExtended *extended);
7982
} ORBPathCallbacksExtended;
8083

81-
static_assert(sizeof(ORBPathCallbacksExtended) == 0x58);
82-
static_assert(offsetof(ORBPathCallbacksExtended, flags) == 0x00);
83-
static_assert(offsetof(ORBPathCallbacksExtended, retain) == 0x08);
84-
static_assert(offsetof(ORBPathCallbacksExtended, release) == 0x10);
85-
static_assert(offsetof(ORBPathCallbacksExtended, apply) == 0x18);
86-
static_assert(offsetof(ORBPathCallbacksExtended, isEqual) == 0x20);
87-
static_assert(offsetof(ORBPathCallbacksExtended, isEmpty) == 0x28);
88-
static_assert(offsetof(ORBPathCallbacksExtended, isSingleElement) == 0x30);
89-
static_assert(offsetof(ORBPathCallbacksExtended, bezierOrder) == 0x38);
90-
static_assert(offsetof(ORBPathCallbacksExtended, boundingRect) == 0x40);
91-
static_assert(offsetof(ORBPathCallbacksExtended, cgPath) == 0x48);
92-
static_assert(offsetof(ORBPathCallbacksExtended, next) == 0x50);
84+
// static_assert without message requires C23 or C++17
85+
#if defined(__cplusplus) || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L)
86+
static_assert(sizeof(struct ORBPathCallbacksExtended) == 0x58);
87+
static_assert(offsetof(struct ORBPathCallbacksExtended, flags) == 0x00);
88+
static_assert(offsetof(struct ORBPathCallbacksExtended, retain) == 0x08);
89+
static_assert(offsetof(struct ORBPathCallbacksExtended, release) == 0x10);
90+
static_assert(offsetof(struct ORBPathCallbacksExtended, apply) == 0x18);
91+
static_assert(offsetof(struct ORBPathCallbacksExtended, isEqual) == 0x20);
92+
static_assert(offsetof(struct ORBPathCallbacksExtended, isEmpty) == 0x28);
93+
static_assert(offsetof(struct ORBPathCallbacksExtended, isSingleElement) == 0x30);
94+
static_assert(offsetof(struct ORBPathCallbacksExtended, bezierOrder) == 0x38);
95+
static_assert(offsetof(struct ORBPathCallbacksExtended, boundingRect) == 0x40);
96+
static_assert(offsetof(struct ORBPathCallbacksExtended, cgPath) == 0x48);
97+
static_assert(offsetof(struct ORBPathCallbacksExtended, next) == 0x50);
98+
#endif
9399

94100
#if ORB_TARGET_OS_DARWIN
95101
/// Global callbacks for CGPath-backed paths

0 commit comments

Comments
 (0)