C embedding problem with 1.9


I can't manage to make the attached program to work with ruby 1.9.

When I run the program, it complain about unknown variable 'a'. Here is
the exact error.

undefined local variable or method `a' for main:Object

If I compile it using ruby 1.8, it works perfectly.

It occurs both on win32 and Ubuntu 9.10.
I tried ruby-1.9.1p243 on linux, and ruby-1.9.1-p376 on windows. I also
tried using a fresh build of the last version from the ruby CVS.

Any idea about the initialization error I certainly made ?




Posted via http://www.ruby-forum.com/.

It seems that using a global variable by adding $ before the 'a'
variable name solve the problem.


Posted via http://www.ruby-forum.com/.

I am still stucked. The follwing code produce the error :
undefined method `synchronize' for #<Mutex:0x83b858c>

int main(int argc, char ** argv){
  int state;
  ruby_sysinit(&argc, &argv);



  rb_eval_string_protect("$mutex = Mutex.new", &state);

  rb_eval_string_protect("$mutex.synchronize() { }", &state);

  return 0;


Posted via http://www.ruby-forum.com/.