Skip to content

Can't create in6_addr #471

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

Closed
Yamakaky opened this issue Dec 12, 2016 · 3 comments
Closed

Can't create in6_addr #471

Yamakaky opened this issue Dec 12, 2016 · 3 comments

Comments

@Yamakaky
Copy link

There is a private __align field, so we can't create it.
https://doc.rust-lang.org/libc/x86_64-unknown-linux-gnu/libc/struct.in6_addr.html

@alexcrichton
Copy link
Member

Thanks for the report! This has also been reported here and here, and unfortunately this is just a place where Rust hasn't historically handled FFI unions very well right now. The underlying type is a union which gains it higher alignment but the exposed fields right now don't give us that alignment. When we have custom alignment we may be able to get around this via other means, but for now you can construct this like you would in C:

let mut foo: libc::in6_addr = mem::uninitialized();
// initialize foo.s6_addr
return foo

Which is to say it's not necessarily "impossible", just not very idiomatic!

@Yamakaky
Copy link
Author

Oh, OK. Maybe add it in the doc? You could also add a method for that.

@alexcrichton
Copy link
Member

Perhaps some general documentation, yes, but I don't think it's particularly necessary to document each and every structure in libc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants