From: Ryan Davis Date: 2007-03-26T03:31:28+09:00 Subject: Re: Ruby with C Your question has already been answered. Alternatively, use inline to learn without all the hassle (no makefile, no builds, no type conversions, no time wasted). Just try out what you want to do straight up in ruby with inlined C, and then go look at what the C code is producing: #!/usr/local/bin/ruby require 'rubygems' require 'inline' class PKey inline do |builder| builder.c <<-EOM static void bit(int n) { printf("Fun %d\\n", n); } EOM end end k = PKey.new k.bit(5) ############################################################ # Produces: # # #include "ruby.h" # # # line 9 "./blah.rb" # static VALUE bit(VALUE self, VALUE _n) { # int n = FIX2INT(_n); # # printf("Fun %d\n", n); # return Qnil; # } # # #ifdef __cplusplus # extern "C" { # #endif # void Init_Inline_PKey_f671() { # VALUE c = rb_cObject; # c = rb_const_get_at(c,rb_intern("PKey")); # rb_define_method(c, "bit", (VALUE(*)(ANYARGS))bit, 1); # # } # #ifdef __cplusplus # } # #endif