From: ruby talk Date: 2006-01-21T12:11:51+09:00 Subject: Re: Extending ruby with c ------=_Part_11397_24049364.1137813098120 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline I am using the pickaxe example to help learn how it is writen. Thank you once again. Becker my run program [code] require "C:\\ruby\\Test" t =3D Test.new() t.add("Bill Chase") [code] my code example from pickaxe saved as a .rb [code] #include "ruby.h" static VALUE t_init(VALUE self) { VALUE arr; arr =3D rb_ary_new(); rb_iv_set(self, "@arr", arr); return self; } static VALUE t_add(VALUE self, VALUE anObject) { VALUE arr; arr =3D rb_iv_get(self, "@arr"); rb_ary_push(arr, anObject); return arr; } VALUE cTest; void Init_Test() { cTest =3D rb_define_class("Test", rb_cObject); rb_define_method(cTest, "initialize", t_init, 0); rb_define_method(cTest, "add", t_add, 1); } [code] error [error] C:\ruby\Test.rb:2: warning: parenthesize argument(s) for future version C:\ruby\Test.rb:2: warning: parenthesize argument(s) for future version c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'= : C:\ruby\Test.rb:4: syntax error (SyntaxError) VALUE arr; ^ C:\ruby\Test.rb:8: syntax error from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require' from testtest.rb:1 [error] On 1/20/06, Eero Saynatkari wrote: > > ruby talk wrote: > > Hello, > > I am looking for an example/tutorial on extending ruby with C using > > windows. > > I add the using windows because I was to extend pcap ruby to windows > > (one > > day), and it is what i currently have installed. I read the pickaxe boo= k > > and > > the example does not work for me. I think my problem with pickaxe > > example is > > the location of my file in the ruby dir. I was getting and error with > > the > > value statment so i removed all the code excpet the return self in the > > functions. and i get > > > > c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > > `require__': > > C:\ruby\lib\ruby\Test.rb:7: void value expression (SyntaxError) > > return self; > > ^ > > C:\ruby\lib\ruby\Test.rb:7: odd number list for Hash > > return self; > > ^ > > C:\ruby\lib\ruby\Test.rb:7: syntax error > > return self; > > ^ > > C:\ruby\lib\ruby\Test.rb:8: syntax error from > > c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > > `require' > > from testtest.rb:1 > > Is return self; in the C code? (The C level does not have an > implicit self.) Does everything compile OK with extconf.rb? > > If you post the code, we can troubleshoot. > > > I read this > > http://www.onlamp.com/pub/a/onlamp/2004/11/18/extending_ruby.html and > > it is > > in linux, make does not work. > > > > Thank you for your time. > > Becker > > > E > > -- > Posted via http://www.ruby-forum.com/. > > ------=_Part_11397_24049364.1137813098120--