Embedding Ruby

DesertPenguin
Unregistered
 
Post: #1
I have decided to try using Ruby instead of Lua for scripting.

I keep getting the following compiler error which is confusing me:
g++ -g -c main.cpp -I/Developer/ruby-1.8.5
main.cpp: In function 'int main(int, const char**)':
main.cpp:21: error: invalid conversion from 'VALUE (*)()' to 'VALUE (*)(...)'
main.cpp:21: error: initializing argument 2 of 'void rb_define_global_function(const char*, VALUE (*)(...), int)'


My source:
VALUE callback(void)
{
printf("C callback\n");

return T_TRUE;
}

int main (int argc, const char * argv[])
{
ruby_init();

// dumps the version info to stdout
ruby_show_version();

//define that callback below
rb_define_global_function("c_callback", callback, 0);

ruby_init_loadpath();

/* //////////////////////////// */
rb_load_file("rubydefs.rb");
int status;
status = ruby_exec();
status = ruby_exec();
status = ruby_cleanup(status);
/* //////////////////////////// */
ruby_finalize();


fprintf(stdout, "this is the end");
return 0;
}


What is VALUE(*)(...) as opposed to VALUE(*)()?

Thanks for any tips....
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #2
... is for variable numbe of args

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #3
Ruby doesn't compile cleanly as C++; you'll need to cast all your function pointers.
Quote this message in a reply
DesertPenguin
Unregistered
 
Post: #4
Thanks - Its working now with:

VALUE callback(...)
{
printf("C callback\n");

return T_TRUE;
}
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Ruby on Rails setting Time to NULL BeyondCloister 3 3,705 Nov 21, 2007 09:56 AM
Last Post: AndyKorth
  Ruby, MacPorts, Firewalls BeyondCloister 3 3,948 Nov 6, 2007 04:57 PM
Last Post: OneSadCookie
  Ruby: Resources for Learning iefan 10 6,686 Jul 4, 2007 08:54 AM
Last Post: ALX99066
  Ruby Gems and OpenGL Jaden 2 2,973 Apr 2, 2007 01:15 AM
Last Post: Jaden
  probably a dumb question about ruby extensions... Duane 3 2,698 Jun 26, 2006 12:33 PM
Last Post: Duane