Quoteing snail / objmedia.demon.co.uk, on Wed, Dec 08, 2004 at 05:02:32AM +0900:
> Hello everyone,
> 
> I'm trying to call a Ruby program from C and pass it some arguments.
> Here is a trivial program that demonstrates the problem. The Ruby
> documentation states that you can set the Ruby arguments using
> ruby_options. I know that if I pass no arguments it waits forever
> listening to STDIN. Thats fine. The problem is that when I do pass
> arguments Ruby just dies - no crash, nothing, just a silent exit.
> 
> Any idea what I'm doing wrong? Should I be using a different call to set
> the arguments?
> 
> I'm using Ruby 1.8.1
> 
> int main(int argc, char* argv[])
> {
>         NtInitialize(&argc, &argv);     // this bit need for Windows
> 
>         ruby_init();
>         ruby_script("embedded");
> 
I don't know anything about ruby here.. but I know the standard format
for ARGV arrays. perhaps you should null terminate rubyArgs?

>         char    *rubyArgs[] =
>         {
>                 "arg1",
>                 "arg2",
>                 "arg3",
                  NULL
>         };

> 
>         // this function should set the arguments to the ruby program
>         // however Ruby silently dies at this point
> 

ruby_options(sizeof(rubyArgs) / sizeof(rubyArgs[0]) - 1, rubyArgs);


Cheers,
Sam

> 
>         // the code never gets here
> 
>         rb_load_file("e:\\doTheWork.rb");
>         ruby_run();
> 
>         return 0;
> }
> 
> Stephen
> -- 
> Stephen Kellett
> Object Media Limited    http://www.objmedia.demon.co.uk
> RSI Information:        http://www.objmedia.demon.co.uk/rsi.html
>