mirror of
https://github.com/ankitects/anki.git
synced 2025-11-06 12:47:11 -05:00
remove CString unwraps
no idea why windows needs an explicit decl, possible compiler bug?
This commit is contained in:
parent
2c018574e1
commit
8ac763ceba
2 changed files with 5 additions and 2 deletions
|
|
@ -36,7 +36,7 @@ macro_rules! load_sym {
|
||||||
macro_rules! ffi {
|
macro_rules! ffi {
|
||||||
($lib:expr, $exec:expr, $($field:ident),* $(,)?) => {
|
($lib:expr, $exec:expr, $($field:ident),* $(,)?) => {
|
||||||
#[allow(clippy::missing_transmute_annotations)] // they're not missing
|
#[allow(clippy::missing_transmute_annotations)] // they're not missing
|
||||||
PyFfi { exec: $exec, $($field: load_sym!($lib, ::std::ffi::CString::new(stringify!($field)).unwrap()),)* lib: $lib, }
|
PyFfi { exec: $exec, $($field: load_sym!($lib, ::std::ffi::CString::new(stringify!($field)).map_err(|_| anyhow::anyhow!("failed to construct symbol CString"))?),)* lib: $lib, }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -297,7 +297,10 @@ macro_rules! load_sym {
|
||||||
macro_rules! ffi {
|
macro_rules! ffi {
|
||||||
($lib:expr, $exec:expr, $($field:ident),* $(,)?) => {
|
($lib:expr, $exec:expr, $($field:ident),* $(,)?) => {
|
||||||
#[allow(clippy::missing_transmute_annotations)] // they're not missing
|
#[allow(clippy::missing_transmute_annotations)] // they're not missing
|
||||||
PyFfi { exec: $exec, $($field: load_sym!($lib, ::std::ffi::CString::new(stringify!($field)).unwrap()),)* lib: $lib.0, }
|
PyFfi { exec: $exec, $($field: {
|
||||||
|
let sym = ::std::ffi::CString::new(stringify!($field)).map_err(|_| anyhow::anyhow!("failed to construct symbol CString"))?;
|
||||||
|
load_sym!($lib, sym)
|
||||||
|
},)* lib: $lib.0, }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue