Skip to content

Commit c200d28

Browse files
committed
Fix static wasm build without wasi
`libc` doesn't have `off_t` for WebAssembly without WASI, so it falls back to `long`. Do the same in this crate to fix the build error when trying to statically build libz for WebAssembly. Rough code from `zconf.h` declaring `z_off_t`: ```c++ #ifndef Z_SOLO # if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) // [...] # ifndef z_off_t # define z_off_t off_t # endif # endif #endif // [...] #ifndef z_off_t # define z_off_t long #endif ``` Fixes #95.
1 parent 59189a0 commit c200d28

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/lib.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@ pub type voidpf = *mut c_void;
2121
pub enum gzFile_s {}
2222
pub enum internal_state {}
2323

24-
#[cfg(feature = "libc")]
24+
#[cfg(all(feature = "libc", not(all(target_family = "wasm", target_os = "unknown"))))]
2525
pub type z_off_t = libc::off_t;
2626

27+
#[cfg(all(feature = "libc", all(target_family = "wasm", target_os = "unknown")))]
28+
pub type z_off_t = c_long;
29+
2730
#[repr(C)]
2831
#[derive(Copy, Clone)]
2932
pub struct gz_header {

0 commit comments

Comments
 (0)