How can I check for the Ruby version inside a C extension? I found some
constants in version.h, but I don't think that file is included via
ruby.h and it has a very common name that may conflicts with similar
files in other projects. So, I don't think it is wise to include
version.h in a Ruby extension.
Is there another way to check if the extension gets compiled with Ruby
1.8 or 1.9?
How can I check for the Ruby version inside a C extension? I found some
constants in version.h, but I don't think that file is included via
ruby.h and it has a very common name that may conflicts with similar
files in other projects. So, I don't think it is wise to include
version.h in a Ruby extension.
Is there another way to check if the extension gets compiled with Ruby
1.8 or 1.9?
Right. This is the problem I have to deal with. My extension uses
rb_frame_last_func() which is subsituted with rb_frame_this_func() in
1.9. So, I have to alter the actual code to use rb_frame_last_func() or
rb_frame_this_func() according to the ruby version installed in the
system.
Should I generate the macro HAVE_RB_FRAME_THIS_FUNC in the Makefile? I
thought Ruby 1.9 had it by default defined in its internals.
Part of extconf.rb for bdb
["rb_frame_this_func", "rb_block_proc", "rb_io_stdio_file"].each do |f|
if have_func(f)
$CFLAGS += " -DHAVE_#{f.upcase}"
end
end
["insert", "values_at"].each do |f|
print "checking for Array##{f}... "
if .respond_to?(f)
puts "yes"
$CFLAGS += " -DHAVE_RB_ARY_#{f.upcase}"
else
puts "no"
end
end