Rb_struct_new

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.

···

--
- nornagon

nornagon wrote:

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.
--
- nornagon

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

nornagon wrote:

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.