Skip to content

Instantly share code, notes, and snippets.

@mikebaldry
Created October 18, 2011 10:55
Show Gist options
  • Save mikebaldry/1295157 to your computer and use it in GitHub Desktop.
Save mikebaldry/1295157 to your computer and use it in GitHub Desktop.
Ruby ext
require 'mkmf'
HEADER_DIRS = ["/opt/local/include"]
LIB_DIRS = ["/opt/local/lib"]
create_makefile("webkitrb")
#include <ruby.h>
static VALUE t_test(VALUE self, VALUE obj)
{
return self;
}
VALUE cMyClass;
void Init_MyClass() {
cMyClass = rb_define_class("MyClass", rb_cObject);
rb_define_method(cMyClass, "test", t_test, 1);
}
g++ -I. -I/Users/clockwize/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0 -I/Users/clockwize/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/i686-darwin10.8.0 -I. -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -fno-common -arch x86_64 -g -Os -pipe -no-cpp-precomp -fno-common -pipe -fno-common -c MyClass.cpp
MyClass.cpp: In function ‘void Init_MyClass()’:
MyClass.cpp:11: error: invalid conversion from ‘VALUE (*)(VALUE, VALUE)’ to ‘VALUE (*)(...)’
MyClass.cpp:11: error: initializing argument 3 of ‘void rb_define_method(VALUE, const char*, VALUE (*)(...), int)’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment