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.
This commit is contained in:
mcb2003 2021-03-06 13:08:31 +00:00
parent b972f44bc9
commit 6b726463cd
1 changed files with 3 additions and 2 deletions

View File

@ -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<E: Into<Vec<u8>>>(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 {