Skip to content

Commit

Permalink
Fix compilation on Wasm (#73)
Browse files Browse the repository at this point in the history
* Fix compilation on Wasm

Fix compilation on WebAssembly, as well as any other non-Windows/Unix/Redox targets.

Previously, the functions would be undefined on those targets and the crate would fail to compile with errors like:
```
error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzCompressInit` in crate `ffi`
   --> src/mem.rs:124:22
    |
124 |                 ffi::BZ2_bzCompressInit(&mut *raw, lvl.level() as c_int, 0, work_factor as c_int),
    |                      ^^^^^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzCompress` in crate `ffi`
   --> src/mem.rs:157:24
    |
157 |             match ffi::BZ2_bzCompress(&mut *self.inner.raw, action as c_int) {
    |                        ^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzDecompressInit` in crate `ffi`
   --> src/mem.rs:215:29
    |
215 |             assert_eq!(ffi::BZ2_bzDecompressInit(&mut *raw, 0, small as c_int), 0);
    |                             ^^^^^^^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzDecompress` in crate `ffi`
   --> src/mem.rs:232:24
    |
232 |             match ffi::BZ2_bzDecompress(&mut *self.inner.raw) {
    |                        ^^^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzCompressEnd` in crate `ffi`
   --> src/mem.rs:312:14
    |
312 |         ffi::BZ2_bzCompressEnd(stream)
    |              ^^^^^^^^^^^^^^^^^ not found in `ffi`

error[E0425]: cannot find function, tuple struct or tuple variant `BZ2_bzDecompressEnd` in crate `ffi`
   --> src/mem.rs:317:14
    |
317 |         ffi::BZ2_bzDecompressEnd(stream)
    |              ^^^^^^^^^^^^^^^^^^^ not found in `ffi`
```

* Update lib.rs
  • Loading branch information
RReverser authored Feb 1, 2021
1 parent 867aca5 commit 707f85c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bzip2-sys/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ macro_rules! abi_compat {
extern "system" {
$(pub fn $name($($arg: $t),*) -> $ret;)*
}
#[cfg(any(unix, target_os = "redox"))]
#[cfg(not(windows))]
extern {
$(pub fn $name($($arg: $t),*) -> $ret;)*
}
Expand Down

0 comments on commit 707f85c

Please sign in to comment.