Skip to content

Commit

Permalink
libc: re-export libc properly
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
posborne committed Mar 11, 2016
1 parent 987dcf4 commit f590b35
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit f590b35

Please sign in to comment.