Skip to content

Commit 9ea5720

Browse files
committed
Fix build in wasm{32,64}-unknown-unknown with zlib feature
``` error[E0432]: unresolved import `libc::c_int` --> src/mem.rs:316:13 | 316 | use libc::c_int; | ^^^^^^^^^^^ no `c_int` in the root error[E0432]: unresolved imports `libc::c_int`, `libc::c_uint`, `libc::c_void`, `libc::size_t` --> src/ffi/c.rs:10:16 | 10 | pub use libc::{c_int, c_uint, c_void, size_t}; | ^^^^^ ^^^^^^ ^^^^^^ ^^^^^^ no `size_t` in the root | | | | | | | no `c_void` in the root | | no `c_uint` in the root | no `c_int` in the root error[E0432]: unresolved imports `libc::c_char`, `libc::c_int` --> src/ffi/c.rs:381:16 | 381 | use libc::{c_char, c_int}; | ^^^^^^ ^^^^^ no `c_int` in the root | | | no `c_char` in the root ```
1 parent 3b2c3a1 commit 9ea5720

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/ffi/c.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ use std::marker;
77
use std::ops::{Deref, DerefMut};
88
use std::ptr;
99

10-
pub use libc::{c_int, c_uint, c_void, size_t};
10+
pub use std::os::raw::{c_int, c_uint, c_void};
11+
12+
#[cfg(not(all(target_family = "wasm", target_os = "unknown")))]
13+
pub use libc::size_t;
1114

1215
use super::*;
1316
use crate::mem::{self, FlushDecompress, Status};
@@ -378,8 +381,8 @@ mod c_backend {
378381
#[cfg(feature = "any_zlib")]
379382
#[allow(bad_style)]
380383
mod c_backend {
381-
use libc::{c_char, c_int};
382384
use std::mem;
385+
use std::os::raw::{c_char, c_int};
383386

384387
#[cfg(feature = "cloudflare_zlib")]
385388
use cloudflare_zlib_sys as libz;

src/mem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ impl Compress {
313313
/// ensures that the function will succeed on the first call.
314314
#[cfg(feature = "any_zlib")]
315315
pub fn set_level(&mut self, level: Compression) -> Result<(), CompressError> {
316-
use libc::c_int;
316+
use std::os::raw::c_int;
317317
let stream = &mut *self.inner.inner.stream_wrapper;
318318
stream.msg = std::ptr::null_mut();
319319

0 commit comments

Comments
 (0)