rb_scan_args question

B

Berger, Daniel

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
 
T

ts

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,137
Messages
2,570,795
Members
47,342
Latest member
eixataze

Latest Threads

Top