From 6b726463cd5fcc62ba4f805cee797a694ab6bc53 Mon Sep 17 00:00:00 2001 From: mcb2003 Date: Sat, 6 Mar 2021 13:08:31 +0000 Subject: [PATCH] FFI: Use std::os::raw::c_char instead of i8 or libc's c_char This fixes an issue where the string pointer type in the generated bindings was const int8_t *. This works the same way, but could be confusing. --- src/ffi.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ffi.rs b/src/ffi.rs index 0fb65ec..717f8e1 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -3,6 +3,7 @@ use std::{ cell::RefCell, ffi::{CStr, CString, NulError}, + os::raw::c_char, ptr, }; @@ -24,7 +25,7 @@ fn set_last_error>>(err: E) -> Result<(), NulError> { /// This string will be valid until at least the next call to `tts_get_error`. /// It is never called internally by the library. #[no_mangle] -pub extern "C" fn tts_get_error() -> *const i8 { +pub extern "C" fn tts_get_error() -> *const c_char { LAST_ERROR.with(|err| match &*err.borrow() { Some(e) => e.as_ptr(), None => ptr::null(), @@ -91,7 +92,7 @@ pub unsafe extern "C" fn tts_supported_features(tts: *const TTS) -> Features { #[no_mangle] pub unsafe extern "C" fn tts_speak( tts: *mut TTS, - text: *const i8, + text: *const c_char, interrupt: bool, utterance: *mut *mut UtteranceId, ) -> bool {