Embedding Ruby

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[])

// dumps the version info to stdout

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


/* //////////////////////////// */
int status;
status = ruby_exec();
status = ruby_exec();
status = ruby_cleanup(status);
/* //////////////////////////// */

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
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
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
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 5,628 Nov 21, 2007 09:56 AM
Last Post: AndyKorth
  Ruby, MacPorts, Firewalls BeyondCloister 3 5,943 Nov 6, 2007 04:57 PM
Last Post: OneSadCookie
  Ruby: Resources for Learning iefan 10 9,995 Jul 4, 2007 08:54 AM
Last Post: ALX99066
  Ruby Gems and OpenGL Jaden 2 4,242 Apr 2, 2007 01:15 AM
Last Post: Jaden
  probably a dumb question about ruby extensions... Duane 3 4,071 Jun 26, 2006 12:33 PM
Last Post: Duane