From: matz@... (Yukihiro Matsumoto) Date: 2000-08-18T00:12:53+09:00 Subject: [ruby-talk:04491] Re: Invoking an extension after compilation Hi, In message "[ruby-talk:04481] Invoking an extension after compilation" on 00/08/16, Dave Thomas writes: |I want to write a C extension module which runs automatically after a |source file has been read, but before it executes. I tried putting the |following in the Init_ function: | | code = NEW_CALL(NEW_CONST(rb_intern("Stuff")), rb_intern("doIt"), 0); | | ruby_eval_tree_begin = block_append(ruby_eval_tree_begin, code); | | |However, this didn't work, because require_libraries in ruby.c saves |and restores the value in ruby_eval_tree_begin. I'm not sure what did you want to do, but I guess rb_eval_string("Stuff.doIt"); or rb_funcall(rb_cStuff, rb_intern("doIt"), 0); at the end of Init_ function may work for you. FYI, registering END block is harder. Use rb_set_end_proc(void (*func)(), VALUE data); matz.