diff --git a/binding-mri/binding-util.h b/binding-mri/binding-util.h
index 83589f7..1b758be 100644
--- a/binding-mri/binding-util.h
+++ b/binding-mri/binding-util.h
@@ -67,7 +67,7 @@ raiseRbExc(const Exception &exc);
 
 /* 2.1 has added a new field (flags) to rb_data_type_t */
 #include <ruby/version.h>
-#if RUBY_API_VERSION_MINOR > 0
+#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 1
 /* TODO: can mkxp use RUBY_TYPED_FREE_IMMEDIATELY here? */
 #define DEF_TYPE_FLAGS 0
 #else
@@ -90,7 +90,12 @@ raiseRbExc(const Exception &exc);
 template<rb_data_type_t *rbType>
 static VALUE classAllocate(VALUE klass)
 {
+/* 2.3 has changed the name of this function */
+#if RUBY_API_VERSION_MAJOR >= 2 && RUBY_API_VERSION_MINOR >= 3
+	return rb_data_typed_object_wrap(klass, 0, rbType);
+#else
 	return rb_data_typed_object_alloc(klass, 0, rbType);
+#endif
 }
 
 template<class C>