[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rb_scan_args question

Berger, Daniel

10/8/2003 1:38:00 PM

Hi all,

2nd attempt - the ML appeared to be defunct yesterday.

Ruby 1.8
Windows XP Pro
VC++ 7

I'm noticing, in Windows at least (not sure about other platforms), some
odd behavior with rb_scan_args. Let's say I have this function:

static VALUE foo(int argc, VALUE *argv)
{
VALUE arg1, arg2;
rb_scan_args(argc,argv,"12",&arg1,&arg2);
return Qnil;
}

What I've noticed is that sometimes this causes a segfault. Sometimes
rather bizarre behavior occurs. The workaround seems to be to add a 3rd
VALUE so that the call looks like this:

rb_scan_args(argc,argv,"12",&arg1,&arg2,&rest);

But, I don't understand why I need the 3rd argument. The "12" states a
minimum of 1 arg and a maximum of 2 args. So, why do I need the 3rd
VALUE?

Please clarify.

Regards,

Dan

1 Answer

ts

10/8/2003 1:42:00 PM

0

>>>>> "B" == Berger, Daniel <djberge@qwest.com> writes:

B> rb_scan_args(argc,argv,"12",&arg1,&arg2);

one mandatory, 2 optionals i.e.

def tt(a, b = nil, c = nil)
end


Guy Decoux