Thanks to all of you about my earlier question.. I had retyped on the linux
box and made the spelling mistake. I will be more careful next time. Thanks
again.
May be one more question about debugging
How do you debug a ruby code. I tried debugging ruby code by using
ruby -r debug testfile
But how do you step into an external code?
--------------------------
I have the following c routine (I have been reading the ruby book about
extensions). I want to define a global variable that can be shared between
ruby and c
which is a hardware_list as defined in the ruby book
------------file: share.c------------------
#include "ruby.h"
VALUE hardware_list;
void Init_Share(){
hardware_list = rb_ary_new();
rb_define_variable("$hardware", &hardware_list);
/*
* push some elts into array
*/
rb_ary_push(hardware_list, rb_str_new2("DVD"));
rb_ary_push(hardware_list, rb_str_new2("CDPlayer1"));
rb_ary_push(hardware_list, rb_str_new2("CDPlayer2"));
}
-------file: extconf.rb------------------------
require 'mkmf'
create_makefile("Share")
--------file: share.rb-------------------------
require "Share"
print "in share.rb\n"
print $hardware
----file: run script------------------------------------------
rm *.o
rm Share.so
ruby extconf.rb
make
ruby share.rb
-----------------------
I tried debugging using
ruby -r debug share.rb
but I can not step into the c code using step. Also, How do you write a
block of comments in ruby code.
Thanks again.
Ram Kochhar