From ced9225aa1496b32950d88520ec4b5e9cae16fdb Mon Sep 17 00:00:00 2001 From: cgmossa Date: Sat, 18 Nov 2023 17:58:44 +0100 Subject: [PATCH] Replace `SEXPREC` with something truly opaque --- build.rs | 3 +++ src/lib.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/build.rs b/build.rs index 89786350..ed3e8c12 100644 --- a/build.rs +++ b/build.rs @@ -520,6 +520,9 @@ fn generate_bindings(r_paths: &InstallationPaths, version_info: &RVersionInfo) { // Remove all Fortran items, these are items with underscore _ postfix let bindgen_builder = bindgen_builder.blocklist_item("[A-Za-z_][A-Za-z0-9_]*[^_]_$"); + // Ensure that `SEXPREC` is opaque to Rust + let bindgen_builder = bindgen_builder.blocklist_item("SEXPREC"); + // Finish the builder and generate the bindings. let bindings = bindgen_builder .raw_line(format!( diff --git a/src/lib.rs b/src/lib.rs index cd882a0a..eae3655d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -66,6 +66,10 @@ include!(concat!(env!("OUT_DIR"), "/bindings.rs")); +#[repr(transparent)] +#[derive(Debug)] +pub struct SEXPREC(std::ffi::c_void); + #[cfg(test)] mod tests { use super::*;