From: Christer Sandberg Date: 2006-09-21T01:43:41+09:00 Subject: Creating a reference to a ruby variable in a C extension. Hi! I'm just making my first C extension and have a question about creating a reference to a ruby variable, that's passed as a method parameter to my C equivalent of initialize. I need this variable to be available after the method has exited because I wan't to call methods on the class represented by that variable. This is what I've done so far after reading the README.EXT etc, static VALUE ref; /* The initialize method. */ static VALUE init(VALUE self, VALUE arg) { ... ref = arg; rb_global_variable(&ref); } Then later on I wan't to use it like this: void call(void) { rb_funcall(ref, rb_intern("some_method"), 0, 0); } Is this the right way to do it or should I solve the problem in another way? Greatful for a fast reply! Thanx Christer -- Posted via http://www.ruby-forum.com/.