[C ext to Ruby] how to read a ruby symbol from C?

I'm now able to produce a ruby symbol from C

I'm also able to read the keys of a hash, i need to know how to
transform a key being a T_SYMBOL into a cstring (the reverse) ???

also using :

long size = RHASH( ( VALUE )options_hash )->tbl->num_entries;

i get the following error at compil time :
symbol_test.c: In function m_symbol_test_init:
symbol_test.c:109: error: dereferencing pointer to incomplete type

i don't understand very much this message.
however i can get the hash size by :

hlen = RARRAY( keys )->len;

with :

VALUE keys = rb_funcall( options_hash, rb_intern( "keys" ), 0 );

my "options_hash" is coming from :

rb_scan_args( argc, argv, "11", &src_path, &options_hash );

it is a VALUE :

VALUE src_path, options_hash, noop, verbose;

help appreciated,

Yvon

Hi,

At Sat, 18 Aug 2007 20:59:59 +0900,
unbewusst wrote in [ruby-talk:265267]:

I'm now able to produce a ruby symbol from C

I'm also able to read the keys of a hash, i need to know how to
transform a key being a T_SYMBOL into a cstring (the reverse) ???

also using :

long size = RHASH( ( VALUE )options_hash )->tbl->num_entries;

i get the following error at compil time :
symbol_test.c: In function m_symbol_test_init:
symbol_test.c:109: error: dereferencing pointer to incomplete type

i don't understand very much this message.

You need to include st.h too.

But I guess what you need first is the knowledge of C.

···

--
Nobu Nakada

OK, thanks, including st.h is OK, BUT using :

rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))

i get allways (null) even if i'm sure, from ruby side the, symbols
are :

:verbose and :noop

isn't the above the correct way to get the name of a symbol ???

Yvon

···

On 19 août, 05:27, Nobuyoshi Nakada <n...@ruby-lang.org> wrote:

You need to include st.h too.

But I guess what you need first is the knowledge of C.

Hi,

At Mon, 20 Aug 2007 01:44:57 +0900,
unbewusst wrote in [ruby-talk:265404]:

rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))

i get allways (null) even if i'm sure, from ruby side the, symbols
are :

:verbose and :noop

isn't the above the correct way to get the name of a symbol ???

That portion you mentioned is correct. So something is wrong
where you didn't.

···

--
Nobu Nakada

OK, i'll look again at that...

thanks,

Yvon

···

On 20 août, 01:40, Nobuyoshi Nakada <n...@ruby-lang.org> wrote:

Hi,

At Mon, 20 Aug 2007 01:44:57 +0900,
unbewusst wrote in [ruby-talk:265404]:

> rb_id2name( SYM2ID( a key T_SYMBOL from a RHASH ))

> i get allways (null) even if i'm sure, from ruby side the, symbols
> are :

> :verbose and :noop

> isn't the above the correct way to get the name of a symbol ???

That portion you mentioned is correct. So something is wrong
where you didn't.