From: Tim Hunter Date: 2006-08-28T21:50:12+09:00 Subject: Re: Version Check in C Extension elias.athanasopoulos@gmail.com wrote: > Hello! > > 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? > > Regards, > Elias > In your extconf.rb file construct a -D option from the RUBY_VERSION constant: VERSION_NUMBER = '0x'+RUBY_VERSION.tr('.','') $CPPFLAGS = "-DRUBY_VERSION=#{VERSION_NUMBER}"