C Extension: mirco RUBY_VM

L

lianliming

Hi all,

I am hacking some existing Ruby c extension, and found code like
following:

#ifdef RUBY_VM
.....
#endif

I want to know the meaning of micro RUBY_VM. I have read some
documents about Ruby C extension like the README.EXT in Ruby source
code. But I can't find anywhere talking about usage of this micro.
Google search only shows me some code using this micro without any
explanation on why and when to use this micro.

Any hints? or is there any online article documenting this micro?

Thanks in advance!
 
K

KUBO Takehiro

Hi Liming,

Hi all,

I am hacking some existing Ruby c extension, and found code like
following:

#ifdef RUBY_VM
.....
#endif

This will be code in ruby-oci8 trunk.
There is no article documenting RUBY_VM.
I use it to check whether the ruby's thread model is green or native,
in other words, whether the ruby version is 1.8 or 1.9.

#ifdef RUBY_VM
code for ruby 1.9
#else
code for ruby 1.8
#endif

I want RUBY_VERSION_MAJOR, RUBY_VERSION_MINOR and so on.
But there is no macro describing ruby version. I use RUBY_VM instead.
 
P

Paul Brannan

I want RUBY_VERSION_MAJOR, RUBY_VERSION_MINOR and so on.
But there is no macro describing ruby version. I use RUBY_VM instead.

In version.h there is:

#define RUBY_VERSION_CODE 190

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0

But unfortunately version.h doesn't get included automatically (IMO it
should -- and it should have include guards as well).

Paul
 
K

KUBO Takehiro

In version.h there is:

#define RUBY_VERSION_CODE 190

#define RUBY_VERSION_MAJOR 1
#define RUBY_VERSION_MINOR 9
#define RUBY_VERSION_TEENY 0

Thanks. I grepped sub directories under 'include' in ruby 1.9
source tree. But version.h is found on the top directory. I have not
noticed it.
But unfortunately version.h doesn't get included automatically (IMO it
should -- and it should have include guards as well).

In addition, version.h is installed on ruby 1.8. but not on 1.9. I cannot
use it.
 
L

lianliming

Hi kubo,

Thanks for your reply. I didn't realize this macro is ruby-oci8
specific. I asked here because I thought it is a common micro in ruby
c library.
 
N

Nobuyoshi Nakada

Hi,

At Tue, 18 Dec 2007 23:56:34 +0900,
KUBO Takehiro wrote in [ruby-talk:284006]:
I use it to check whether the ruby's thread model is green or native,
in other words, whether the ruby version is 1.8 or 1.9.

#ifdef RUBY_VM
code for ruby 1.9
#else
code for ruby 1.8
#endif

They should be `code for ruby with VM' and `code for ruby
without VM'.
I want RUBY_VERSION_MAJOR, RUBY_VERSION_MINOR and so on.
But there is no macro describing ruby version. I use RUBY_VM instead.

Check if a feature you want to use is supported. You should
not rely on cryptic version number check.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,222
Messages
2,571,142
Members
47,775
Latest member
MadgeMatti

Latest Threads

Top