Nested structures and C extensions

D

Donnie Brasco

Hey everybody,

I've been wrestling with an issue in writing a Ruby extension with C.
I'm seeing that I can access (without Bus errors) top level attributes
in my initial structure that aren't nestled into another C structure
that is a member of this initial structure.

On the other hand, if I try to access the members of some structure that
is a member of the base structure after setting up a pointer to that
base structure via Data_Get_Struct, I get Bus errors. Even after
initializing all those variables in my C initializer, they don't come
back initialized when I pull them from a C implementation of an accessor
method.

I read some older posts under "Data_Make_Struct() considered dangerous?"
and the original poster described what may have been my problem. I'm
not really sure what the conclusion to that thread was, however. I'm
dealing with structs that contain multiple structs which, in turn,
contain other structs (along with regular primitive data such as
integers, etc.). I'm finding that the top-level structs give me easy,
Bus error-free access to things like integers and chars. Things get
hairy when I try to access structs from within instances of structs
after having created a pointer with Data_Get_Struct.

I'm not really interested in using SWIG, etc., so does anybody have any
ideas about how to go about fixing this problem?

Thanks in advance!
 

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,189
Messages
2,571,016
Members
47,616
Latest member
gijoji4272

Latest Threads

Top