#include #include "ruby.h" RUBY_GLOBAL_SETUP static VALUE eval(const char * string) { int state; VALUE v = rb_eval_string_protect(string, &state); if (state != 0) { fprintf(stderr, "rb_eval_string_protect() returned state %d!\n", state); rb_set_errinfo(Qnil); } return v; } int main(int argc, char *argv[]) { ruby_sysinit(&argc, &argv); { RUBY_INIT_STACK; ruby_init(); ruby_init_loadpath(); VALUE v = eval("3 + 8"); printf("v: %d\n", FIX2INT(v)); eval("File.open('out.txt', 'w') {|fh| fh.puts 'hello!'}"); eval("puts 'Hello, World!'"); ruby_finalize(); } return 0; }