ts wrote: >>>>>>"B" == Basile STARYNKEVITCH <basile-news / starynkevitch.net> writes: > > > B> // file testemb_ruby.c > > write it like this > > svg% cat testembed_ruby.c > #include <stdio.h> > #include <stdlib.h> > #include <ruby.h> > > int execute(int argc, char **argv) > { > int state = 0; > char *script = 0; > char *cmd = 0; > VALUE res = 0; > > if (argc > 1) { > script = argv[1]; > printf ("loading ruby script %s\n", script); > ruby_script (script); > rb_load_protect (rb_str_new2(script), Qfalse, &state); > printf ("after load_file errinfo="); > rb_p (ruby_errinfo); > } > if (argc > 2) > cmd = argv[2]; > else > cmd = "sayhello(\"world\")"; > printf ("before eval %s\n", cmd); > res = rb_eval_string_protect (cmd, &state); > printf ("after eval state=%d res=", state); > rb_p (res); > printf ("after eval errinfo="); > rb_p (ruby_errinfo); > return state; > } > > int main (int argc, char **argv) > { > ruby_init (); > ruby_init_loadpath (); /* to find the libraries */ > return execute(argc, argv); > } // end of main > svg% > > > svg% testembed_ruby myscript.rb > loading ruby script myscript.rb > loaded myscript.rb > after load_file errinfo=nil > before eval sayhello("world") > hello world > after eval state=0 res=#<IO:0x400a0258> > after eval errinfo=nil > svg% That's interesting; does this way work because Ruby marks the stack and it was being loaded within an if block, and moving the load calls to a permanent place on the stack solves the problem? Sean O'Dell