Skip to content

Commit f590b35

Browse files
committed
libc: re-export libc properly
With rust 1.7, the following warning was being emitted by the compiler: warning: `pub extern crate` does not work as expected and should not be used. Likely to become an error. Prefer `extern crate` and `pub use`. Based on rust-lang/rust#26775 it appears that the warning in 1.7 which was to be escalated to an error is going away but in older versions of rust it is still the case that `pub extern crate` will not work as expected. Instead, we use a somewhat creative hack to export the libc root as a module in nix. Down the line, it may make sense to either eliminate the need to export libc (by chaning the ioctl macros) or to move toward deprecated older versions of rustc. Signed-off-by: Paul Osborne <[email protected]>
1 parent 987dcf4 commit f590b35

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,17 @@ extern crate bitflags;
1616
#[macro_use]
1717
extern crate cfg_if;
1818

19-
pub extern crate libc;
20-
2119
#[cfg(test)]
2220
extern crate nix_test as nixtest;
2321

24-
// Re-exports
22+
// In rust 1.8+ this should be `pub extern crate libc` but prior
23+
// to https://github.com/rust-lang/rust/issues/26775 being resolved
24+
// it is necessary to get a little creative.
25+
pub mod libc {
26+
extern crate libc;
27+
pub use self::libc::*;
28+
}
29+
2530
pub use libc::{c_int, c_void};
2631
pub use errno::Errno;
2732

0 commit comments

Comments
 (0)