From: Vincent Fourmond Date: 2006-09-21T03:37:49+09:00 Subject: Re: Creating a reference to a ruby variable in a C extension. Hello ! > Then later on I wan't to use it like this: > > void call(void) > { > rb_funcall(ref, rb_intern("some_method"), 0, 0); > } How comes this function has no parameters ? Is it being called from ruby, or only from C code ? I tend to think that using global variables is not a really good idea. We need a bit more context about what you want to do. Is it a class ? Will it have several instances ? In the latter case, have a look at rb_iv_get and rb_iv_set to get/set instance variables of a class instance, something like rb_iv_set(self, rb_intern("@variable"), arg); /* in init(...) */ and rb_funcall(rb_iv_get(self,rb_intern("@variable")),rb_intern("some_method"), 0, 0); /* in call */ Don't forget as well that every single C function that can be called directly from ruby should probably have at least one VALUE parameter and *must* return a VALUE. Cheers ! Vince