Tim Hunter
1/21/2006 3:25:00 AM
ruby talk wrote:
> 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 = 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 = rb_ary_new();
> rb_iv_set(self, "@arr", arr);
> return self;
> }
>
> static VALUE t_add(VALUE self, VALUE anObject)
> {
> VALUE arr;
> arr = rb_iv_get(self, "@arr");
> rb_ary_push(arr, anObject);
> return arr;
> }
>
> VALUE cTest;
>
> void Init_Test() {
> cTest = 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;
> ^
You do understand that you have to compile the C code and link it into a
..dll, don't you?