(Ruby 1.9.1) error: ‘struct RString’ has no member named ‘ptr’

Hi, trying to compile a C extension I get this error in Ruby 1.9.1:

  error: ‘struct RString’ has no member named ‘ptr’

The code is:

···

---------------------------------------
#include <ruby.h>
#include <stdio.h>

static VALUE my_method(VALUE self, VALUE arg) {
  
  char* name = RSTRING(arg)->ptr;
---------------------------------------

I find in ruby.h:

-------------------------------------------
struct RString {
    struct RBasic basic;
    union {
        struct {
            long len;
            char *ptr;
            union {
                long capa;
                VALUE shared;
            } aux;
        } heap;
        char ary[RSTRING_EMBED_LEN_MAX + 1];
    } as;
};
------------------------------------------

Perhaps a change from 1.8? How should I access the "ptr" element?
Thanks.

--
Iñaki Baz Castillo
<ibc@aliax.net>

It seems that I mut use:

  char* name = RSTRING_PTR(arg);

Am I right?

···

2009/4/3 Iñaki Baz Castillo <ibc@aliax.net>:

Hi, trying to compile a C extension I get this error in Ruby 1.9.1:

error: ‘struct RString’ has no member named ‘ptr’

The code is:

---------------------------------------
#include <ruby.h>
#include <stdio.h>

static VALUE my_method(VALUE self, VALUE arg) {

   char\* name = RSTRING\(arg\)\-&gt;ptr;

---------------------------------------

--
Iñaki Baz Castillo
<ibc@aliax.net>

Autoreply: yes :slight_smile:

···

2009/4/3 Iñaki Baz Castillo <ibc@aliax.net>:

---------------------------------------
#include <ruby.h>
#include <stdio.h>

static VALUE my_method(VALUE self, VALUE arg) {

   char\* name = RSTRING\(arg\)\-&gt;ptr;

---------------------------------------

It seems that I mut use:

   char\* name = RSTRING\_PTR\(arg\);

Am I right?

--
Iñaki Baz Castillo
<ibc@aliax.net>