[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Ruby 1.9.1) error: â??struct RStringâ?? has no memb er named â??ptrâ??

Iñaki Baz Castillo

4/3/2009 3:36:00 PM

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

error: =E2=80=98struct RString=E2=80=99 has no member named =E2=80=98ptr=
=E2=80=99

The code is:

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

static VALUE my_method(VALUE self, VALUE arg) {
=09
char* name =3D 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.


--=20
I=C3=B1aki Baz Castillo
<ibc@aliax.net>

2 Answers

Iñaki Baz Castillo

4/3/2009 3:38:00 PM

0

2009/4/3 I=C3=B1aki Baz Castillo <ibc@aliax.net>:
> Hi, trying to compile a C extension I get this error in Ruby 1.9.1:
>
> =C2=A0error: =E2=80=98struct RString=E2=80=99 has no member named =E2=80=
=98ptr=E2=80=99
>
> The code is:
>
> ---------------------------------------
> #include <ruby.h>
> #include <stdio.h>
>
> static VALUE my_method(VALUE self, VALUE arg) {
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0char* name =3D RSTRING(arg)->ptr;
> ---------------------------------------

It seems that I mut use:

char* name =3D RSTRING_PTR(arg);

Am I right?


--=20
I=C3=B1aki Baz Castillo
<ibc@aliax.net>

Iñaki Baz Castillo

4/3/2009 3:43:00 PM

0

2009/4/3 I=C3=B1aki Baz Castillo <ibc@aliax.net>:

>> ---------------------------------------
>> #include <ruby.h>
>> #include <stdio.h>
>>
>> static VALUE my_method(VALUE self, VALUE arg) {
>>
>> =C2=A0 =C2=A0 =C2=A0 =C2=A0char* name =3D RSTRING(arg)->ptr;
>> ---------------------------------------
>
> It seems that I mut use:
>
> =C2=A0 =C2=A0 =C2=A0 =C2=A0char* name =3D RSTRING_PTR(arg);
>
> Am I right?

Autoreply: yes :)

--=20
I=C3=B1aki Baz Castillo
<ibc@aliax.net>