From f590b356a4f4d7a726349882a944ca37e0895a6f Mon Sep 17 00:00:00 2001 From: Paul Osborne Date: Fri, 4 Mar 2016 21:46:46 -0600 Subject: [PATCH] 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 https://github.com/rust-lang/rust/issues/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 --- src/lib.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index f368fc5739..f3724ec3ed 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -16,12 +16,17 @@ extern crate bitflags; #[macro_use] extern crate cfg_if; -pub extern crate libc; - #[cfg(test)] extern crate nix_test as nixtest; -// Re-exports +// In rust 1.8+ this should be `pub extern crate libc` but prior +// to https://github.com/rust-lang/rust/issues/26775 being resolved +// it is necessary to get a little creative. +pub mod libc { + extern crate libc; + pub use self::libc::*; +} + pub use libc::{c_int, c_void}; pub use errno::Errno;