SpaceManiac / opus-rs

Safe Rust bindings for libopus
Apache License 2.0
70 stars 64 forks source link

Fix invalid type on ARM #2

Closed valleyflowerbear closed 8 years ago

valleyflowerbear commented 8 years ago

This fixes the compile error on ARM.

Is there a better way to do this?

SpaceManiac commented 8 years ago

I'm not sure, it seems like something is afoot here:

fn opus_strerror(error: ::libc::c_int) -> *const ::libc::c_char;
fn opus_get_version_string() -> *const ::libc::c_char;
unsafe fn from_ptr<'a>(ptr: *const c_char) -> &'a CStr;

What are the actual mismatched type errors you are seeing?

valleyflowerbear commented 8 years ago
/src/lib.rs:109:26: 109:56 error: mismatched types:
 expected `*const u8`,
    found `*const i8` [E0308]
/src/lib.rs:109     unsafe { CStr::from_ptr(ffi::opus_get_version_string()) }.to_str().unwrap()
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/src/lib.rs:109:26: 109:56 help: run `rustc --explain E0308` to see a detailed explanation
/src/lib.rs:525:45: 525:69 error: mismatched types:
 expected `*const u8`,
    found `*const i8` [E0308]
/src/lib.rs:525         let description = unsafe { CStr::from_ptr(ffi::opus_strerror(code)) }.to_str().unwrap();
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/src/lib.rs:525:45: 525:69 help: run `rustc --explain E0308` to see a detailed explanation
SpaceManiac commented 8 years ago

As I suspected, it looks like mismatched versions of libc are the root problem. For target arm-unknown-linux-gnueabi:

I've opened https://github.com/lgvz/rust-opus/pull/3 in an effort to fix the root cause.

valleyflowerbear commented 8 years ago

That explains it! Closing this for now.