From: Andre Nathan Date: 2013-03-11T21:03:51+09:00 Subject: Returning File::Stat objects from a C extension Hello I'm trying to find out how to return File::Stat objects from a C extension. In 1.8 I can do it like this: #define WRAP_STAT(stp) Data_Wrap_Struct(rb_cStat, NULL, free, stp) static VALUE stat_new(struct stat *st) { struct stat *stp = ALLOC(struct stat); *stp = *st; return WRAP_STAT(stp); } Starting in 1.9 it seems the correct way would be to do it like this: static size_t stat_memsize(const void *p) { return p ? sizeof(struct stat) : 0; } static const rb_data_type_t stat_data_type = { "stat", {NULL, RUBY_TYPED_DEFAULT_FREE, stat_memsize,}, }; #define WRAP_STAT(stp) \ TypedData_Wrap_Struct(rb_cStat, &stat_data_type, stp) However this leads to the following error: #