-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arrays in a C struct #33
Comments
Yes, that would be great! Just one warning: we use a quite old version of the readstat lib. I've started work to get us up to speed with the latest version by using BinaryBuilder and compiling a new version, but that is not done yet. I'm not sure whether there are any changes to these types upstream, but just something to keep in mind. |
I looked at the main repo and it seems that they have changed that struct quite a few times so if we really want to match it in Julia, we'd have to be careful with checking the version of the linked library. However, there are quite a few getter functions defined so it is safer and simpler to just rely on them instead of trying to match the struct in Julia. |
So that maybe suggests that we don't even need to define these structs at all, but can just pass a pointer around and then use the getter functions to access things, right? That seems an all around safer approach. |
@davidanthoff Yes. I think it will be safer overall to use the getter functions and not try to emulate the C structs. I am working on a PR. |
I was wrong about passing |
Well, I didn't write any of this code ;) This julia package was original created by Evan Miller, who is the creator for the ReadStat C library. He is no longer interested in maintaining the julia package, so he transferred the repo over to me because I had helped out getting it to run on Windows a while back. So really he deserves the credit for any of this here. |
@davidanthoff Would you be willing to transfer ownership to the |
I'm happy to keep maintaining it. I like the model where someone is on the hook if things don't work, and for now I'm happy to be that person ;) If I run out of time to do that, we could move it over. |
I noticed in reading the code that the Julia struct
does not align with the C declaration in
readstat,h
The problem is that the fixed-size
char
arrays, likename
do not correspond toPtr{UInt8}
orCstring
in Julia. If you want the structs to align in memory you need to insert a Julia struct that has the correct width. TheClang
package at one time did this by creating a Juliastruct
with 256UInt8
fields and inserting that as thename
field. However, that approach is rather tedious.In this case there is no need to define the Julia struct because the memory is allocated in the C code and passed by reference. I can prepare a PR if you wish.
The text was updated successfully, but these errors were encountered: