From: _why Date: 2008-11-27T15:58:02+09:00 Subject: [ruby-core:20138] Re: Ruby class variable access from C On Thu, Nov 27, 2008 at 04:49:32AM +0900, Christopher Thompson wrote: > I think I can get it by doing: > VALUE myvar = rb_eval_string("Myclass::myvar"); > but surely there's a better way? I'm thinking something like > rb_cvar_get() but that requires that I pass in a VALUE and all I have is > a string at this point, "Myclass". If you create the class in your C extension, you'll get a VALUE back. VALUE cMyclass; void Init_myext() { cMyclass = rb_define_class("Myclass", rb_cObject); } VALUE much_much_later(VALUE self) { VALUE myvar = rb_cvar_get(cMyclass, rb_intern("@@myvar")); } _why