From: "Niklas C." Date: 2008-04-29T14:15:51+09:00 Subject: Re: converting strings in c extension Whow, that really gave me a hint! Doing ldist 'foo','bar' now prints: main 'foo' So for some reason main is given as the first argument. Does ruby always do that? doesn't make much sense to me... Anyway, I solved the problem by adding another (first) parameter to rb_ldist, but still specifying 2 parameters down in the rb_define_method call. Seems like a dirty hack but it's working, thank's a lot ;) Joel VanderWerf wrote: > Niklas C. wrote: >> While trying to bind some old C code to ruby I ran into trouble >> converting strings. The function in question requires two string >> arguments (const char*). This is the relevant part of my binding: >> > > Try adding the following lines to see what the objects really are: > >> ... >> static VALUE rb_ldist(VALUE s, VALUE t) >> { > rb_p(s); > rb_p(t); >> return INT2FIX(ldist(StringValuePtr(s),StringValuePtr(t))); >> } >> ... > > (Btw, README.EXT should mention this function. It's very useful.) -- Posted via http://www.ruby-forum.com/.