Skip to content

Commit d6ace94

Browse files
authored
bugfix: Fix use of i8 instead of c_char causing build failures on Linux (#45)
The code mistakenly assumed that c_char was i8 on all Rust platforms, but that is not true on Linux, so this is causing type mismatch errors at build time on Linux. (This mistake of mine was presumably reinforced by Rust issue #15823, which is an issue with rustdoc rendering some type aliases in function signatures as the pointed-to type and not by the alias name, which--among other effects--causes CStr::from_raw() and CString::into_raw() to show `i8` in their type signatures instead of `c_char`.) See also: rust-lang/rust#15823
1 parent 9f11f9b commit d6ace94

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ mod test_readme {
160160

161161

162162
use std::convert::TryFrom;
163-
use std::ffi::{CStr, CString};
163+
use std::ffi::{c_char, CStr, CString};
164164
use std::fmt::{self, Display};
165165
use std::net;
166166

@@ -516,7 +516,7 @@ impl Link {
516516
pub fn open_with_args(args: &[&str]) -> Result<Self, Error> {
517517
// NOTE: Before returning, we must convert these back into CString's to
518518
// deallocate them.
519-
let mut c_strings: Vec<*mut i8> = args
519+
let mut c_strings: Vec<*mut c_char> = args
520520
.into_iter()
521521
.map(|&str| {
522522
CString::new(str)
@@ -623,7 +623,7 @@ impl Link {
623623
let Link { raw_link } = *self;
624624

625625
unsafe {
626-
let name: *const i8 = self::sys::WSName(raw_link as *mut _);
626+
let name: *const c_char = self::sys::WSName(raw_link as *mut _);
627627
CStr::from_ptr(name).to_str().unwrap().to_owned()
628628
}
629629
}
@@ -652,7 +652,7 @@ impl Link {
652652
pub fn error(&self) -> Option<Error> {
653653
let Link { raw_link } = *self;
654654

655-
let (code, message): (i32, *const i8) =
655+
let (code, message): (i32, *const c_char) =
656656
unsafe { (sys::WSError(raw_link), WSErrorMessage(raw_link)) };
657657

658658
if code == sys::MLEOK || message.is_null() {

0 commit comments

Comments
 (0)