From: Sylvain Joyeux Date: 2007-06-19T16:07:52+09:00 Subject: Re: Problem wrapping the C++ STL > g++ -Wall -I. -I/opt/lib/ruby/1.8/i686-darwin8.9.1 > -I/opt/lib/ruby/1.8/i686-darwin8.9.1 -I. -fno-common -g -O2 -pipe > -fno-common -c cvector.c > cvector.c: In function 'void Init_cvector()': > cvector.c:10: error: invalid conversion from 'VALUE (*)(int, VALUE*, > VALUE)' to 'VALUE (*)(...)' > cvector.c:10: error: initializing argument 3 of 'void > rb_define_method(VALUE, const char*, VALUE (*)(...), int)' > make: *** [cvector.o] Error 1 C++ is more pissy than C about type convertions. You have to use the RUBY_METHOD_FUNC macro to convert cvector_init into the right type: rb_define_method(cVector, "initialize", RUBY_METHOD_FUNC(cvector_init), -1); > > Note that you can wrap std::vector directly (no need to go through an > > intermediate cvector structure) > > I guess I could store it as an instance variable within the constructor > and refer back to it that way. I don't think it's faster, though. Or, > did you have something else in mind? The idea is *not* to use a cvector structure. Since you'll have to provide an alloc/free method pair anyway, allocate std::vector in them. Check value_set_alloc/value_set_free in http://www.laas.fr/~sjoyeux/darcs/utilrb/ext/value_set.cc Sylvain