Skip to content

Commit cb01b90

Browse files
committed
rtypeddata.h: Add missing RBIMPL_CAST
In public headers, casts should be enclosed in `RBIMPL_CAST` for compilation in C++.
1 parent 9e78353 commit cb01b90

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

include/ruby/internal/core/rtypeddata.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ RBIMPL_SYMBOL_EXPORT_END()
476476
*/
477477
#define TypedData_Make_Struct0(result, klass, type, size, data_type, sval) \
478478
VALUE result = rb_data_typed_object_zalloc(klass, size, data_type); \
479-
(sval) = (type *)RTYPEDDATA_GET_DATA(result); \
479+
(sval) = RBIMPL_CAST((type *)RTYPEDDATA_GET_DATA(result)); \
480480
RBIMPL_CAST(/*suppress unused variable warnings*/(void)(sval))
481481

482482
/**
@@ -594,7 +594,7 @@ RBIMPL_ATTR_ARTIFICIAL()
594594
* @return Data type struct that corresponds to `obj`.
595595
* @pre `obj` must be an instance of ::RTypedData.
596596
*/
597-
static inline const struct rb_data_type_struct *
597+
static inline const rb_data_type_t *
598598
RTYPEDDATA_TYPE(VALUE obj)
599599
{
600600
#if RUBY_DEBUG
@@ -604,7 +604,8 @@ RTYPEDDATA_TYPE(VALUE obj)
604604
}
605605
#endif
606606

607-
return (const struct rb_data_type_struct *)(RTYPEDDATA(obj)->type & TYPED_DATA_PTR_MASK);
607+
VALUE type = RTYPEDDATA(obj)->type & TYPED_DATA_PTR_MASK;
608+
return RBIMPL_CAST((const rb_data_type_t *)type);
608609
}
609610

610611
RBIMPL_ATTR_ARTIFICIAL()

0 commit comments

Comments
 (0)