Skip to content

Commit 139044c

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 5bac9df commit 139044c

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
@@ -13,12 +13,17 @@
1313
#[macro_use]
1414
extern crate bitflags;
1515

16-
pub extern crate libc;
17-
1816
#[cfg(test)]
1917
extern crate nix_test as nixtest;
2018

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

0 commit comments

Comments
 (0)