Skip to content

Commit ab5b3e6

Browse files
committed
Fix type macros for C++
They are now used in arginfo files.
1 parent 44fa68b commit ab5b3e6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

Zend/zend_types.h

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,28 +263,36 @@ typedef struct {
263263
#define ZEND_TYPE_ALLOW_NULL(t) \
264264
(((t).type_mask & _ZEND_TYPE_NULLABLE_BIT) != 0)
265265

266+
#ifdef __cplusplus
267+
# define _ZEND_TYPE_PREFIX zend_type
268+
#else
269+
/* FIXME: We could add (zend_type) here at some point but this breaks in MSVC because
270+
* (zend_type)(zend_type){} is no longer considered constant. */
271+
# define _ZEND_TYPE_PREFIX
272+
#endif
273+
266274
#define ZEND_TYPE_INIT_NONE(extra_flags) \
267-
{ NULL, (extra_flags) }
275+
_ZEND_TYPE_PREFIX { NULL, (extra_flags) }
268276

269277
#define ZEND_TYPE_INIT_MASK(_type_mask) \
270-
{ NULL, (_type_mask) }
278+
_ZEND_TYPE_PREFIX { NULL, (_type_mask) }
271279

272280
#define ZEND_TYPE_INIT_CODE(code, allow_null, extra_flags) \
273281
ZEND_TYPE_INIT_MASK(((code) == _IS_BOOL ? MAY_BE_BOOL : ( (code) == IS_ITERABLE ? _ZEND_TYPE_ITERABLE_BIT : ((code) == IS_MIXED ? MAY_BE_ANY : (1 << (code))))) \
274282
| ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags))
275283

276284
#define ZEND_TYPE_INIT_PTR(ptr, type_kind, allow_null, extra_flags) \
277-
{ (void *) (ptr), \
285+
_ZEND_TYPE_PREFIX { (void *) (ptr), \
278286
(type_kind) | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags) }
279287

280288
#define ZEND_TYPE_INIT_PTR_MASK(ptr, type_mask) \
281-
{ (void *) (ptr), (type_mask) }
289+
_ZEND_TYPE_PREFIX { (void *) (ptr), (type_mask) }
282290

283291
#define ZEND_TYPE_INIT_UNION(ptr, extra_flags) \
284-
{ (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) }
292+
_ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_UNION_BIT) | (extra_flags) }
285293

286294
#define ZEND_TYPE_INIT_INTERSECTION(ptr, extra_flags) \
287-
{ (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) }
295+
_ZEND_TYPE_PREFIX { (void *) (ptr), (_ZEND_TYPE_LIST_BIT|_ZEND_TYPE_INTERSECTION_BIT) | (extra_flags) }
288296

289297
#define ZEND_TYPE_INIT_CLASS(class_name, allow_null, extra_flags) \
290298
ZEND_TYPE_INIT_PTR(class_name, _ZEND_TYPE_NAME_BIT, allow_null, extra_flags)

0 commit comments

Comments
 (0)