Using rb_require with rb_protect to embed Ruby in C -
i want use rb_require rb_protect, in following example:
int error; rb_protect( (value (*)(value))rb_require, (value) "./test", &error);
but when compile it, error:
passing argument 1 of ‘rb_protect’ incompatible pointer type [enabled default] /usr/include/ruby-1.9.1/ruby/intern.h:357:7: note: expected ‘value (*)(value)’ argument of type ‘value (*)(value, value)’
after searching on google see how use rb_require rb_protect, tried:
int error; rb_protect( ruby_method_func(rb_require), (value) "./test", &error);
or
value require_wrap(value arg) { return rb_require("./test"); } /*in main:*/ rb_protect( require_wrap, 0, & error);
but same error. error doesn't stop compilation binary segfault when launch whereas works without rb_protect.
__edit__
there error in source file. in fact solutions have tested works well:
int error; rb_protect( (value (*)(value))rb_require, (value) "./test", &error);
or
int error; rb_protect( ruby_method_func(rb_require), (value) "./test", &error);
or
value require_wrap(value arg) { return rb_require("./test"); } /*in main:*/ rb_protect( require_wrap, 0, & error);
thanks
solutions works well:
int error; rb_protect( (value (*)(value))rb_require, (value) "./test", &error);
or
int error; rb_protect( ruby_method_func(rb_require), (value) "./test", &error);
or
value require_wrap(value arg) { return rb_require("./test"); } /*in main:*/ rb_protect( require_wrap, 0, & error);
Comments
Post a Comment