Answered: What is proper ruby ffi code for this 开发者_Python百科function:
void glutInit(int *argc, char ** argv);
attach_function :glutInit, [:pointer, :pointer], :void
Answered: How to handle array of C-strings? Like a pointer!
Still unanswered:How to change ARGV to match argument type?
If you know how to get "untouched" C argc and argv in Ruby script it would also helped (eg. python have special library for that, I'm not aware of anything similar for Ruby apart from ARGV).
here someone has written about this: http://zegoggl.es/2009/05/ruby-ffi-recipes.html
you can use :varargs in your attach_function call, and when you call gluInit, you pass an array of type/value pairs.
精彩评论