-
Notifications
You must be signed in to change notification settings - Fork 677
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
Export types from function signatures, or libc in general #226
Comments
Many of them are in |
This should be fixed... However, the exact strategy is still TBD (#190). If an FFI type is used in a function signature, it should be exported by libc. However, nix may want to create its own types and wrap the libc FFI types in order to provide stricter type safety as well as custom functions on the types. |
The problem with types exported by libc is that cargo is a bit silly with pulling multiple libraries. (rust-lang/cargo#2064) This results in "it's T, but not the right version of T" errors unless the local cargo.toml is kept in sync with nix's cargo.toml all the time. If nix forwarded just the plain pid_t (and other affected types), it would make the maintenance easier, because libc wouldn't have to be specified anymore. |
What do you mean by this? I'm not all caught up on how the multiple versions of a Crate stuff works, but I definitely agree we want a good answer here. |
It's hard to explain in practice beyond "bad things happen if you don't ensure there's only one libc"... I'll try to create a minimal example. |
Suppose we have two versions of libc (A and B). Further assume that we have to libraries: foo and bar. Now if bar exports a function like this: extern crate libc;
use libc;
fn baz(libc::c_int) {} and foo uses it as follows extern crate libc;
extern crate bar;
fn call_baz() {
let a : libc::c_int = 3;
baz(a);
} then you'd get an error. Because If nix-rust exported libc under I don't suggest every library exports all its dependencies. But in this case nix and libc are so closely related, that I think it makes sense. |
Are there other alternatives to that? Seems a bit... icky! |
I think this was resolved by #284. Though I do believe |
I've found that there's a number of types like pid_t which are either function results or arguments, but they're not explicitly exported. This means either I have to depend on libc myself and track the version nix depends on, or use a hacky solution (pid_t is available via nix::sys::ioctl::libc::pid_t).
It would be great if the types used in public signatures were either available through nix in a more straightforward way, or if the libc was available via nix::libc.
The text was updated successfully, but these errors were encountered: