# Ruby 1.9 porting problem

**URL:** <https://www.ruby-forum.com/t/ruby-1-9-porting-problem/124724>\
**Category:** Ruby\
**Created:** [January 1, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/ruby-1-9-porting-problem/124724 "2008-01-01T20:49:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![s450r1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@s450r1](https://www.ruby-forum.com/u/s450r1)\
**Post date:** [January 1, 2008, 8:49pm UTC](https://www.ruby-forum.com/t/ruby-1-9-porting-problem/124724/1 "2008-01-01T20:49:40Z")

</div>

I am having problems porting my extension to 1.9.

I’m doing something like:

static VALUE my\_alloc(VALUE klass)  
{  
return Data\_Wrap\_Struct(klass, NULL, my\_free, NULL);  
}  
…  
static VALUE my\_init(int argc, VALUE \*argv, VALUE self)  
{  
…  
Check\_Type(self,T\_DATA);  
DATA\_PTR(self) = my\_var;  
…  
}

But on the “Check\_Type(self,T\_DATA)” I get:  
“[BUG] unknown type 0x12”.

This worked fine in 1.8. What’s the correct way to do this in 1.9?

Regards,  
Jeff D.

---

<div class="post-metadata">

**Author:** ![s450r1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@s450r1](https://www.ruby-forum.com/u/s450r1)\
**Post date:** [January 1, 2008, 11:00pm UTC](https://www.ruby-forum.com/t/ruby-1-9-porting-problem/124724/2 "2008-01-01T23:00:24Z")

</div>

Jeff D. wrote:

> {  
> …  
> Check\_Type(self,T\_DATA);  
> DATA\_PTR(self) = my\_var;

That generally should work. Have you tried with a non-NULL value in  
Data\_Wrap\_Struct? Have you tried a 0-ary method first?

static VALUE my\_init(VALUE self)  
{  
…  
Check\_Type(self,T\_DATA);  
DATA\_PTR(self) = my\_var;

Regards,

Michael

---

<div class="post-metadata">

**Author:** ![s450r1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/87869e/32.png) [@s450r1](https://www.ruby-forum.com/u/s450r1)\
**Post date:** [January 1, 2008, 11:52pm UTC](https://www.ruby-forum.com/t/ruby-1-9-porting-problem/124724/3 "2008-01-01T23:52:31Z")

</div>

On Wed, 2008-01-02 at 06:59 +0900, Michael N. wrote:

> > static VALUE my\_init(int argc, VALUE \*argv, VALUE self)  
> > {  
> > …  
> > Check\_Type(self,T\_DATA);  
> > DATA\_PTR(self) = my\_var;

Thank you for the reply. I think I found the problem: I was compiling  
the extension against ruby 1.9, but when I ran irb, I was mistakenly  
running irb 1.8.

Too many combinations of installations to keep track of when trying to  
do portability testing 😉

Regards,  
Jeff D.
