On Jun 19, 1:07 am, Sylvain J. [email protected]
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:
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
Interesting, thank you. For kicks, I tried to compile your source code
on my Solaris 10 box (after installing boost). It built (with some
warnings), but I can’t get it to load.
Here’s the extconf.rb file I used:
CONFIG[‘CC’] = ‘CC’
CONFIG[‘CC’] = ‘g++ -Wall’
Here was the result of the build step:
djberge-/export/home/djberge/workspace/set/ext-635>ruby extconf.rb –
CC -I. -I/usr/local/lib/ruby/1.8/sparc-solaris2.10 -I/usr/local/lib/
ruby/1.8/sparc-solaris2.10 -I. -I/opt/csw/include -KPIC -dalign -fns -
xbuiltin=%all -xlibmil -xtarget=ultra2e -xO5 -xipo -c set.c
“set.c”, line 349: Warning (Anachronism): Formal argument 3 of type
extern “C” unsigned long()(…) in call to rb_iterate(extern “C”
unsigned long()(unsigned long), unsigned long, extern “C” unsigned
long()(…), unsigned long) is being passed unsigned long()(…).
“set.c”, line 369: Warning (Anachronism): Formal argument 2 of type
extern “C” unsigned long()(unsigned long) in call to
rb_define_alloc_func(unsigned long, extern “C” unsigned long()
(unsigned long)) is being passed unsigned long(*)(unsigned long).
2 Warning(s) detected.
ld -G -o set2.so set.o -L’.’ -L’/usr/local/lib’ -R’/usr/local/lib’ -
L. -lrt -lpthread -ldl -lcrypt -lm -lc
Ok, a couple warnings. I proceed to try to “require ‘set2’” and I get
/export/home/djberge/workspace/set/ext/set2.so: ld.so.1: ruby: fatal:
relocation error: file /export/home/djberge/workspace/set/ext/set2.so:
symbol _1cDstdJbad_allocG__vtbl: referenced symbol not found - /
This was with Ruby 1.8.6-p38 (today’s svn checkout of the 1.8.6