ruby extension problem

P

Philliam Auriemma

Hey guys,
I am writing a ruby extension in C++ that exposes a function to ruby,
and then opens a ruby interpreter that loads a file that can call the
function.

I am following the Pragmatic Programmers guide to embedding and
extending ruby. I have a function defined like this:

static VALUE Send (VALUE length, VALUE capMode, VALUE dev, VALUE pack)

then later to register it, there is this:

VALUE cTest;

void Init_Send() {
cTest = rb_define_module("rpacket");
rb_define_module_function(cTest, "Send", Send, 4);
}

However, when compiling, I get this error:

error C2664: 'rb_define_module_function' : cannot convert parameter 3
from 'VALUE (__cdecl *)(VALUE,VALUE,VALUE,VALUE)' to 'VALUE (__cdecl *)
(...)'

Anyone know why it's failing?
 
A

Aaron Patterson

Hey guys,
I am writing a ruby extension in C++ that exposes a function to ruby,
and then opens a ruby interpreter that loads a file that can call the
function.

I am following the Pragmatic Programmers guide to embedding and
extending ruby. I have a function defined like this:

static VALUE Send (VALUE length, VALUE capMode, VALUE dev, VALUE pack)

This function needs to take a leading VALUE which holds a reference to the
recipient of the call. Try this instead:

static VALUE Send (VALUE mod, VALUE length, VALUE capMode, VALUE dev, VALUE pack)
 
P

Philliam Auriemma

This function needs to take a leading VALUE which holds a reference to the
recipient of the call.  Try this instead:

  static VALUE Send (VALUE mod, VALUE length, VALUE capMode, VALUE dev,VALUE pack)

I still have a similar error:

1>.\main.cpp(45) : error C2664: 'rb_define_module_function' : cannot
convert parameter 3 from 'VALUE (__cdecl *)
(VALUE,VALUE,VALUE,VALUE,VALUE)' to 'VALUE (__cdecl *)(...)'
1> None of the functions with this name in scope match the
target type

Line 45 is the

rb_define_module_function(cTest, "Send", Send, 4);
 

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

Forum statistics

Threads
474,001
Messages
2,570,250
Members
46,848
Latest member
Graciela Mitchell

Latest Threads

Top