rb_struct_new

N

nornagon

Hi. I'm documenting a C extension, and I'm having a little bit of
trouble figuring out what rb_struct_new does. I would check the return
value of that particular function, but I am currently running windows
and the extension is linux-only.

Could anyone point me in the right direction?

Thanks.
--=20
- nornagon
 
T

Tim Hunter

nornagon said:
Hi. I'm documenting a C extension, and I'm having a little bit of
trouble figuring out what rb_struct_new does. I would check the return
value of that particular function, but I am currently running windows
and the extension is linux-only.

Could anyone point me in the right direction?

Thanks.

It's basically the same as the Ruby code "Struct.new". The first
argument is the name of the new class. Succeeding arguments are the
names of the structure fields. The last argument is NULL. It returns a
new Struct class.
 
D

Daniel Berger

nornagon said:
Hi. I'm documenting a C extension, and I'm having a little bit of
trouble figuring out what rb_struct_new does. I would check the return
value of that particular function, but I am currently running windows
and the extension is linux-only.

Could anyone point me in the right direction?

Thanks.

It creates a new struct, one that you've defined previously with
rb_struct_define(). So, something like this:

VALUE rbMyStruct = rb_struct_define("MyStruct","foo","bar",0);
VALUE rbVal = rb_struct_new(rbMyStruct, ...);

I'm not sure why you think this is a Linux only function. It works
perfectly fine on Windows.

Regards,

Dan
 

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

Forum statistics

Threads
474,172
Messages
2,570,934
Members
47,478
Latest member
ReginaldVi

Latest Threads

Top