In C extension code, what's the canonical way to test whether the ruby
being compiled against is 1.8 or 1.9?
[...]
But this seems accidental. However I didn't find a RUBY_VERSION constant
in the headers anywhere.
[...]
In C extension code, what's the canonical way to test whether the ruby being compiled against is 1.8 or 1.9?
[...]
But this seems accidental. However I didn't find a RUBY_VERSION constant in the headers anywhere.
[...]
Thanks, this looked perfect. I wondered why my 'grep VERSION include/ruby/*.h' hadn't found this. Turns out version.h is deliberately not installed for ruby 1.9, although it is in the source tree:
May I suggest a different approach, with the fast evolution of Ruby I
would rather not check for the version but for features. (Like e.g.
Object detection vs. Browser detection in Javascript)
E.g.
begin
Object.method :tap
rescue NameError
Object.module_eval do
def tap &blk; instance_eval( &blk ); self end
end
end
The above example, that I actually used, came to full value when I
upgraded from 8.6 to 8.7