From: 7stud -- Date: 2009-08-27T01:26:28+09:00 Subject: Re: Help with C embedding Khat Harr wrote: > I'm having trouble with a weird error that I don't understand the cause > of. The error is coming from this line: > PspCtrlButtons cbutt = (PspCtrlButtons)NUM2ULONG(button); Specifically, the function call: NUM2ULONG(button) As Brian Candler pointed out, your function signature here is faulty: VALUE input_trigger(VALUE button) You are actually doing something like this: static VALUE input_trigger(VALUE self) { unsigned long num = NUM2ULONG(self); } The first parameter variable of a function automatically gets assigned self. As a consequence, if you want to pass one argument to a function, you have to define the function with two parameter variables: the first parameter variable will be assigned self, and the second parameter variable will be assigned the argument you pass. In your code, the first parameter variable is named 'button', and when you call the function, self is automatically assigned to the first parameter variable, so self gets assigned to button. Because a module is calling the function, self is the module, and the function NUM2ULONG can't convert a module to an int (an unsigned long integer in this case). > //this gets called during initialization: > rb_define_module_function(ruby_input_mod, "trigger?", > (VALUE (*)(...))input_trigger, 1); > Next, that cast to a variadic function produces an error when I compile the code: error: ISO C requires a named argument before ‘...’ -- Posted via http://www.ruby-forum.com/.