From: Patrick Hurley Date: 2007-03-19T08:50:21+09:00 Subject: Re: Problem trying to use varargs in private function within C extension On 3/18/07, Daniel Berger wrote: > On Mar 18, 10:01 am, "Patrick Hurley" wrote: > > Dan, > > > > In you example pure C code you are calling test with 2 parameters in > > your ruby code, only one. Your prototype has one mandatory param, and > > the function actually has two. If you change: > > > > total = test("hello"); > > > > to > > > > total = test("hello", 3); > > > > Does it compile? > > pth > > Yes, the C code compiles either way. The Ruby code will only compile > if I provide the 2nd argument. > > Regards, > > Dan > > > Then, my next guess is that it is the order of the prototypes and the actual function. In the C example you have a prototype (one param), use, definition (with two+ params). In the Ruby example you have prototype, definition (2+ params, over rides prototype), use. Move the init_foo, up where your main is in the stand alone example. FYI accessing the second parameter if you do not pass it, is likely to cause a memory exception on many platforms (depending upon call depth, build mode, etc). pth